columnFormat.js
6.57 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
describe('columnFormat', function() {
beforeEach(function() {
affix('#cal');
});
describe('when columnFormat is not set', function() {
var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
{ view: 'basicWeek', expected: 'Sun 5/11', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaWeek', expected: 'Sun 5/11', selector: 'th.fc-widget-header.fc-sun' },
{ view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ];
beforeEach(function() {
$('#cal').fullCalendar({
defaultDate: '2014-05-11'
});
});
it('should have default values', function() {
var cal = $('#cal');
for (var i = 0; i < viewWithFormat.length; i++) {
var crtView = viewWithFormat[i];
cal.fullCalendar('changeView', crtView.view);
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
};
});
});
describe('when columnFormat is set on a per-view basis', function() {
var viewWithFormat = [ { view: 'month', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
{ view: 'basicWeek', expected: 'Sunday 11 - 5', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaWeek', expected: 'Sunday 11 , 5', selector: 'th.fc-widget-header.fc-sun' },
{ view: 'basicDay', expected: 'Sunday 11 | 5', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaDay', expected: 'Sunday 5/11', selector: 'th.fc-widget-header.fc-sun' } ];
beforeEach(function() {
$('#cal').fullCalendar({
defaultDate: '2014-05-11',
columnFormat: {
month: 'dddd',
agendaDay: 'dddd M/D',
agendaWeek: 'dddd D , M',
basicDay: 'dddd D | M',
basicWeek: 'dddd D - M'
}
});
});
it('should have the correct values', function() {
var cal = $('#cal');
for (var i = 0; i < viewWithFormat.length; i++) {
var crtView = viewWithFormat[i];
cal.fullCalendar('changeView', crtView.view);
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
};
});
});
describe('when lang is French', function() {
var viewWithFormat = [ { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' },
{ view: 'basicWeek', expected: 'dim. 11/5', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaWeek', expected: 'dim. 11/5', selector: 'th.fc-widget-header.fc-sun' },
{ view: 'basicDay', expected: 'dimanche', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' } ];
beforeEach(function() {
$('#cal').fullCalendar({
defaultDate: '2014-05-11',
lang: 'fr'
});
});
it('should have the translated dates', function() {
var cal = $('#cal');
for (var i = 0; i < viewWithFormat.length; i++) {
var crtView = viewWithFormat[i];
cal.fullCalendar('changeView', crtView.view);
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
};
});
});
describe('when lang is Korean', function() {
var viewWithFormat = [ { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' },
{ view: 'basicWeek', expected: '일 5.11', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaWeek', expected: '일 5.11', selector: 'th.fc-widget-header.fc-sun' },
{ view: 'basicDay', expected: '일요일', selector: 'th.fc-day-header.fc-sun' },
{ view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ];
beforeEach(function() {
$('#cal').fullCalendar({
defaultDate: '2014-05-11',
lang: 'ko'
});
});
it('should have the translated dates and columnFormat should be computed differently', function() {
var cal = $('#cal');
for (var i = 0; i < viewWithFormat.length; i++) {
var crtView = viewWithFormat[i];
cal.fullCalendar('changeView', crtView.view);
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
};
});
});
describe('using custom views', function() {
it('multi-year default only displays day-of-week', function() {
$('#cal').fullCalendar({
views: {
multiYear: {
type: 'basic',
duration: { years: 2 }
}
},
defaultView: 'multiYear',
defaultDate: '2014-12-25'
});
expect($('.fc-day-header:first')).toHaveText('Sun');
});
it('multi-month default only displays day-of-week', function() {
$('#cal').fullCalendar({
views: {
multiMonth: {
type: 'basic',
duration: { months: 2 }
}
},
defaultView: 'multiMonth',
defaultDate: '2014-12-25'
});
expect($('.fc-day-header:first')).toHaveText('Sun');
});
it('multi-week default only displays day-of-week', function() {
$('#cal').fullCalendar({
views: {
multiWeek: {
type: 'basic',
duration: { weeks: 2 }
}
},
defaultView: 'multiWeek',
defaultDate: '2014-12-25'
});
expect($('.fc-day-header:first')).toHaveText('Sun');
});
it('multi-day default displays short full date', function() {
$('#cal').fullCalendar({
views: {
multiDay: {
type: 'basic',
duration: { days: 2 }
}
},
defaultView: 'multiDay',
defaultDate: '2014-12-25'
});
expect($('.fc-day-header:first')).toHaveText('Thu 12/25');
});
});
});