aspectRatio.js
3.95 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
describe('aspectRatio', function() {
beforeEach(function() {
affix('#cal');
});
describe('when default settings are used', function() {
beforeEach(function() {
$('#cal').width(675);
$('#cal').fullCalendar();
});
it('fc-content should use the ratio 1:35 to set height', function() {
var height = $('.fc-view-container').height();
expect(height).toEqual(500);
});
it('fc-content should have width of div', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(675);
});
});
describe('when initializing the aspectRatio', function() {
describe('to 2', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: 2
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should set the height to width sizes very close to ratio of 2', function() {
var width = $('.fc-view-container').width();
var height = $('.fc-view-container').height();
var ratio = Math.round(width / height * 100);
expect(ratio).toEqual(200);
});
});
describe('to 1', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: 1
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should set the height to width sizes very close to ratio of 2', function() {
var width = $('.fc-view-container').width();
var height = $('.fc-view-container').height();
var ratio = Math.round(width / height * 100);
expect(ratio).toEqual(100);
});
});
describe('to less than 0.5', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: 0.4
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should set the height to width ratio to 0.5', function() {
var width = $('.fc-view-container').width();
var height = $('.fc-view-container').height();
var ratio = Math.round(width / height * 100);
expect(ratio).toEqual(50);
});
});
describe('to negative', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: -2
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should set the height to width ratio to 0.5', function() {
var width = $('.fc-view-container').width();
var height = $('.fc-view-container').height();
var ratio = Math.round(width / height * 100);
expect(ratio).toEqual(50);
});
});
describe('to zero', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: 0
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should set the height to width ratio to 0.5', function() {
var width = $('.fc-view-container').width();
var height = $('.fc-view-container').height();
var ratio = Math.round(width / height * 100);
expect(ratio).toEqual(50);
});
});
describe('to very large', function() {
beforeEach(function() {
$('#cal').width(1000);
$('#cal').fullCalendar({
aspectRatio: 4000
});
});
it('should not change the width', function() {
var width = $('.fc-view-container').width();
expect(width).toEqual(1000);
});
it('should cause rows to be natural height', function() {
var actualHeight = $('.fc-view-container').height();
$('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red');
var naturalHeight = $('.fc-view-container').height();
expect(actualHeight).toEqual(naturalHeight);
});
});
});
});