weekMode.js
6.22 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
describe('weekMode', function() {
beforeEach(function() {
affix('#cal');
});
describe('when weekMode is default', function() {
beforeEach(function() {
$('#cal').fullCalendar();
});
it('should show 6 weeks for a 5 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should show 6 weeks for a 4 week month', function() {
$('#cal').fullCalendar('gotoDate', '2009-03-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should show 6 weeks for a 6 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should not change height whether 4,5 or weeks', function() {
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var fourWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var sixWeekHeight = $('.fc-week:first').outerHeight();
expect(fourWeekHeight).toBeGreaterThan(0);
expect(fiveWeekHeight).toBeGreaterThan(0);
expect(sixWeekHeight).toBeGreaterThan(0);
expect(fourWeekHeight).toEqual(fiveWeekHeight);
expect(fiveWeekHeight).toEqual(sixWeekHeight);
});
});
describe('when weekMode is set to fixed', function() {
beforeEach(function() {
$('#cal').fullCalendar({
weekMode: 'fixed'
});
});
it('should show 6 weeks for a 5 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should show 6 weeks for a 4 week month', function() {
$('#cal').fullCalendar('gotoDate', '2009-03-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should show 6 weeks for a 6 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
});
describe('when weekMode is set to liquid', function() {
beforeEach(function() {
$('#cal').fullCalendar({
weekMode: 'liquid'
});
});
it('should show 5 weeks for a 5 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(5);
});
it('should show 4 weeks for a 4 week month', function() {
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(4);
});
it('should show 6 weeks for a 6 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should increase height when moving from 6 week to 5 weeks', function() {
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var sixWeekHeight = $('.fc-week:first').outerHeight();
expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
});
it('should reduce height when moving from 5 weeks to 6 weeks', function() {
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var sixWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
});
it('should increase height when moving from 5 weeks to 4 weeks', function() {
$('#cal').fullCalendar('gotoDate', '2013-05-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var fourWeekHeight = $('.fc-week:first').outerHeight();
expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
});
it('should reduce height when moving from 4 weeks to 5 weeks', function() {
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var fourWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-05-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
});
});
it('should not display an empty week when no visible days and weekMode is set to liquid', function() {
$('#cal').fullCalendar({
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
weekMode: 'liquid',
weekends: false
});
expect($('.fc-week').length).toBe(4);
});
describe('when weekMode is set to variable', function() {
beforeEach(function() {
$('#cal').fullCalendar({
weekMode: 'variable'
});
});
it('should show 5 weeks for a 5 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(5);
});
it('should show 4 weeks for a 4 week month', function() {
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(4);
});
it('should show 6 weeks for a 6 week month', function() {
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var weekCount = $('.fc-week').length;
expect(weekCount).toEqual(6);
});
it('should not change height whether 4,5 or weeks', function() {
$('#cal').fullCalendar('gotoDate', '2009-02-01');
var fourWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-10-01');
var fiveWeekHeight = $('.fc-week:first').outerHeight();
$('#cal').fullCalendar('gotoDate', '2013-06-01');
var sixWeekHeight = $('.fc-week:first').outerHeight();
expect(fourWeekHeight).toBeGreaterThan(0);
expect(fiveWeekHeight).toBeGreaterThan(0);
expect(sixWeekHeight).toBeGreaterThan(0);
expect(fourWeekHeight).toEqual(fiveWeekHeight);
expect(fiveWeekHeight).toEqual(sixWeekHeight);
});
});
it('should not display an empty week when no visible days and weekMode is set to variable', function() {
$('#cal').fullCalendar({
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
weekMode: 'variable',
weekends: false
});
expect($('.fc-week').length).toBe(4);
});
});