weekNumberCalculation.js
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
describe('weekNumberCalculation', function() {
var options;
beforeEach(function() {
options = {
weekNumbers: true
};
});
function getRenderedWeekText() {
// works for both kinds of views
return $('.fc-agenda-view .fc-week-number, .fc-week:first .fc-content-skeleton .fc-week-number').text();
}
function getRenderedWeekNumber() {
var text = getRenderedWeekText() || '';
return parseInt(text.replace(/\D/g, ''), 10);
}
beforeEach(function() {
affix('#cal');
});
[ 'basicDay', 'agendaDay' ].forEach(function(viewType) {
describe('when in ' + viewType + ' view', function() {
beforeEach(function() {
options.defaultView = viewType;
});
it('should display the American standard when using \'local\'', function() {
options.defaultDate = '2013-11-23'; // a Saturday
options.weekNumberCalculation = 'local';
$('#cal').fullCalendar(options);
expect(getRenderedWeekNumber()).toBe(47);
});
it('should display a language-specific local week number', function() {
options.defaultDate = '2013-11-23'; // a Saturday
options.lang = 'ar';
options.weekNumberCalculation = 'local';
$('#cal').fullCalendar(options);
expect(getRenderedWeekText()).toMatch(/٤٨|48/);
});
// another local test, but to make sure it is different from ISO
it('should display the American standard when using \'local\'', function() {
options.defaultDate = '2013-11-17'; // a Sunday
options.weekNumberCalculation = 'local';
$('#cal').fullCalendar(options);
expect(getRenderedWeekNumber()).toBe(47);
});
it('should display ISO standard when using \'ISO\'', function() {
options.defaultDate = '2013-11-17'; // a Sunday
options.weekNumberCalculation = 'ISO';
$('#cal').fullCalendar(options);
expect(getRenderedWeekNumber()).toBe(46);
});
it('should display the calculated number when a custom function', function() {
options.weekNumberCalculation = function() {
return 4;
};
$('#cal').fullCalendar(options);
expect(getRenderedWeekNumber()).toBe(4);
});
});
});
});