|
|
@@ -1,139 +1,164 @@
|
|
|
|
|
|
describe('aspectRatio', function() {
|
|
|
|
|
|
- beforeEach(function() {
|
|
|
- affix('#cal');
|
|
|
- });
|
|
|
+ function getCalendarElement(width) {
|
|
|
+ return $('<div id="calendar">').appendTo('body').width(width)[0];
|
|
|
+ }
|
|
|
|
|
|
describe('when default settings are used', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(675);
|
|
|
- $('#cal').fullCalendar();
|
|
|
- });
|
|
|
+
|
|
|
+ var elementWidth = 675;
|
|
|
+
|
|
|
it('fc-content should use the ratio 1:35 to set height', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var height = $('.fc-view-container').height();
|
|
|
expect(Math.round(height)).toEqual(500);
|
|
|
});
|
|
|
+
|
|
|
it('fc-content should have width of div', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(675);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('when initializing the aspectRatio', function() {
|
|
|
|
|
|
+ var elementWidth = 1000;
|
|
|
+
|
|
|
describe('to 2', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: 2
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: 2
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should set the height to width sizes very close to ratio of 2', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
var height = $('.fc-view-container').height();
|
|
|
var ratio = Math.round(width / height * 100);
|
|
|
expect(Math.round(ratio)).toEqual(200);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('to 1', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: 1
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: 1
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should set the height to width sizes very close to ratio of 2', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
var height = $('.fc-view-container').height();
|
|
|
var ratio = Math.round(width / height * 100);
|
|
|
expect(Math.round(ratio)).toEqual(100);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('to less than 0.5', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: 0.4
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: 0.4
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should set the height to width ratio to 0.5', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
var height = $('.fc-view-container').height();
|
|
|
var ratio = Math.round(width / height * 100);
|
|
|
expect(Math.round(ratio)).toEqual(50);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('to negative', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: -2
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: -2
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should set the height to width ratio to 0.5', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
var height = $('.fc-view-container').height();
|
|
|
var ratio = Math.round(width / height * 100);
|
|
|
expect(Math.round(ratio)).toEqual(50);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('to zero', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: 0
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: 0
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should set the height to width ratio to 0.5', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
var height = $('.fc-view-container').height();
|
|
|
var ratio = Math.round(width / height * 100);
|
|
|
expect(Math.round(ratio)).toEqual(50);
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
|
|
|
describe('to very large', function() {
|
|
|
- beforeEach(function() {
|
|
|
- $('#cal').width(1000);
|
|
|
- $('#cal').fullCalendar({
|
|
|
- aspectRatio: 4000
|
|
|
- });
|
|
|
+
|
|
|
+ pushOptions({
|
|
|
+ aspectRatio: 4000
|
|
|
});
|
|
|
+
|
|
|
it('should not change the width', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
var width = $('.fc-view-container').width();
|
|
|
- expect(Math.round(width)).toEqual(1000);
|
|
|
+ expect(Math.round(width)).toEqual(elementWidth);
|
|
|
});
|
|
|
+
|
|
|
it('should cause rows to be natural height', function() {
|
|
|
+ initCalendar({}, getCalendarElement(elementWidth));
|
|
|
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(Math.round(actualHeight)).toEqual(Math.round(naturalHeight));
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
});
|