minTime.js
3.51 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
describe('minTime', function() {
beforeEach(function() {
affix('#cal');
});
var numToStringConverter = function(timeIn, mins) {
var time = (timeIn % 12) || 12;
var amPm = 'am';
if ((timeIn % 24) > 11) {
amPm = 'pm';
}
return time + (mins != null ? ':' + mins : '') + amPm;
};
describe('when using the default settings', function() {
describe('in agendaWeek', function() {
it('should start at 12am', function() {
var options = {
defaultView: 'agendaWeek'
};
$('#cal').fullCalendar(options);
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
expect(firstSlotText).toEqual('12am');
});
});
describe('in agendaDay', function() {
it('should start at 12am', function() {
var options = {
defaultView: 'agendaDay'
};
$('#cal').fullCalendar(options);
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
expect(firstSlotText).toEqual('12am');
});
});
});
describe('when using a whole number', function() {
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
describe('in agendaWeek', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should start at ' + hourNumber, function() {
var options = {
defaultView: 'agendaWeek',
minTime: { hours: hourNumber }
};
$('#cal2').fullCalendar(options);
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
var expected = numToStringConverter(hourNumber);
expect(firstSlotText).toEqual(expected);
});
});
});
describe('in agendaDay', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should start at ' + hourNumber, function() {
var options = {
defaultView: 'agendaDay',
minTime: hourNumber + ':00' // in addition, test string duration input
};
$('#cal2').fullCalendar(options);
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
var expected = numToStringConverter(hourNumber);
expect(firstSlotText).toEqual(expected);
});
});
});
});
describe('when using default slotInterval and \'uneven\' minTime', function() {
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
describe('in agendaWeek', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should start at ' + hourNumber + ':20', function() {
var options = {
defaultView: 'agendaWeek',
minTime: { hours: hourNumber, minutes: 20 }
};
$('#cal2').fullCalendar(options);
var slatRows = $('.fc-slats tr');
expect(slatRows.eq(0)).toHaveClass('fc-minor');
expect(slatRows.eq(1)).toHaveClass('fc-minor');
expect(slatRows.eq(2)).toHaveClass('fc-minor');
// TODO: fix bad behavior in src where no slots have text
});
});
});
describe('in agendaDay', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should start at ' + hourNumber + ':20', function() {
var options = {
defaultView: 'agendaDay',
minTime: { hours: hourNumber, minutes: 20 }
};
$('#cal2').fullCalendar(options);
var slatRows = $('.fc-slats tr');
expect(slatRows.eq(0)).toHaveClass('fc-minor');
expect(slatRows.eq(1)).toHaveClass('fc-minor');
expect(slatRows.eq(2)).toHaveClass('fc-minor');
// TODO: fix bad behavior in src where no slots have text
});
});
});
});
});