From 2bbbbf678e939d96a67ed355496c84113d18c5a6 Mon Sep 17 00:00:00 2001 From: Gareth Leachman Date: Mon, 23 Sep 2013 22:43:29 +0100 Subject: [PATCH 01/14] beginnings of an automated testing framework (Karma and Jasmine) written by Gareth Leachman, squashed and reformatted by Adam Shaw --- karma.conf.IntegrationTests.js | 63 +++++ specs/fullCalendar.js | 65 +++++ ...CalendarSpecs-AgendaOptions-allDaySlots.js | 80 ++++++ ...lCalendarSpecs-AgendaOptions-allDayText.js | 81 ++++++ ...fullCalendarSpecs-AgendaOptions-minTime.js | 132 ++++++++++ ...CalendarSpecs-AgendaOptions-slotMinutes.js | 96 ++++++++ .../fullCalendarSpecs-options-aspectRatio.js | 140 +++++++++++ ...fullCalendarSpecs-options-contentHeight.js | 49 ++++ specs/fullCalendarSpecs-options-firstDay.js | 166 +++++++++++++ ...alendarSpecs-options-handleWindowResize.js | 19 ++ specs/fullCalendarSpecs-options-header.js | 79 ++++++ ...llCalendarSpecs-options-headerDateClick.js | 60 +++++ specs/fullCalendarSpecs-options-height.js | 49 ++++ specs/fullCalendarSpecs-options-hiddenDays.js | 87 +++++++ specs/fullCalendarSpecs-options-isRTL.js | 231 ++++++++++++++++++ specs/fullCalendarSpecs-options-weekMode.js | 148 +++++++++++ ...ndarSpecs-options-weekNumberCalculation.js | 36 +++ .../fullCalendarSpecs-options-weekNumbers.js | 38 +++ specs/fullCalendarSpecs-options-weekends.js | 31 +++ ...pecs-optionsCombinations-firstDay-isRTL.js | 26 ++ ...onsCombinations-weekNumbers-defaultView.js | 141 +++++++++++ tests/base.css | 12 + 22 files changed, 1829 insertions(+) create mode 100644 karma.conf.IntegrationTests.js create mode 100644 specs/fullCalendar.js create mode 100644 specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js create mode 100644 specs/fullCalendarSpecs-AgendaOptions-allDayText.js create mode 100644 specs/fullCalendarSpecs-AgendaOptions-minTime.js create mode 100644 specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js create mode 100644 specs/fullCalendarSpecs-options-aspectRatio.js create mode 100644 specs/fullCalendarSpecs-options-contentHeight.js create mode 100644 specs/fullCalendarSpecs-options-firstDay.js create mode 100644 specs/fullCalendarSpecs-options-handleWindowResize.js create mode 100644 specs/fullCalendarSpecs-options-header.js create mode 100644 specs/fullCalendarSpecs-options-headerDateClick.js create mode 100644 specs/fullCalendarSpecs-options-height.js create mode 100644 specs/fullCalendarSpecs-options-hiddenDays.js create mode 100644 specs/fullCalendarSpecs-options-isRTL.js create mode 100644 specs/fullCalendarSpecs-options-weekMode.js create mode 100644 specs/fullCalendarSpecs-options-weekNumberCalculation.js create mode 100644 specs/fullCalendarSpecs-options-weekNumbers.js create mode 100644 specs/fullCalendarSpecs-options-weekends.js create mode 100644 specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js create mode 100644 specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js create mode 100644 tests/base.css diff --git a/karma.conf.IntegrationTests.js b/karma.conf.IntegrationTests.js new file mode 100644 index 0000000..fcec513 --- /dev/null +++ b/karma.conf.IntegrationTests.js @@ -0,0 +1,63 @@ +// Karma configuration +// Generated on Wed Sep 18 2013 21:29:48 GMT+0100 (GMT Daylight Time) +module.exports = function(config) { + config.set({ + + // base path, that will be used to resolve files and exclude + basePath: '', + + // frameworks to use + frameworks: [ 'jasmine' ], + + // list of files / patterns to load in the browser + files: [ + { pattern: './lib/jquery/jquery.js', watched: false }, + { pattern: './lib/jquery-simulate/*.js', watched: false }, + { pattern: './lib/jasmine-jquery/*.js', watched: false }, + { pattern: './lib/jquery-ui/ui/jquery-ui.js', watched: false }, + { pattern: './lib/jquery-ui/ui/jquery.ui.draggable.js', watched: false }, + { pattern: './lib/jasmine-fixture/*.js', watched: false }, + './build/out/fullcalendar.js', + './build/out/fullcalendar.css', + './build/out/fullcalendar.print.css', + './specs/fullCalendar*.js' + ], + + // list of files to exclude + exclude: [], + + // test results reporter to use + // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' + reporters: [ 'dots' ], + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera + // - Safari (only Mac) + // - PhantomJS + // - IE (only Windows) + browsers: [ 'PhantomJS' ], + + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 60000, + + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: false + }); +}; \ No newline at end of file diff --git a/specs/fullCalendar.js b/specs/fullCalendar.js new file mode 100644 index 0000000..520e9ac --- /dev/null +++ b/specs/fullCalendar.js @@ -0,0 +1,65 @@ +'use strict'; +describe('fullCalendar(Integration) :', function() { + + beforeEach(function() { + affix('#calendar'); + }); + + describe('When fullCalendar() is called on a div', function() { + + beforeEach(function() { + $('#calendar').fullCalendar(); + }); + + it('should contain a table fc-header ', function() { + var header = $('#calendar > table.fc-header'); + expect(header[0]).not.toBeUndefined(); + }); + + it('should contain a div fc-content ', function() { + var content = ($('#calendar > div.fc-content')); + expect(content[0]).not.toBeUndefined(); + }); + + it('should only contain 2 elements ', function() { + var calenderNodeCount = $('#calendar >').length; + expect(calenderNodeCount).toEqual(2); + }); + + describe('and then called again', function() { + it('should still only have a single set of calendar [header,content]', function() { + $('#calendar').fullCalendar(); + var count = $('#calendar >').length; + expect(count).toEqual(2); + }); + }); + + // can't do event dragging yet. + // need to work out how fullCalendar is intercepting events. + xdescribe('when event is dragged from one cell to another', function() { + it('should move to the new cell', function() { + var eventName = 'xyzAllDayEvent'; + $('#calendar').fullCalendar({ + editable: true + }); + $('#calendar').fullCalendar('addEventSource', { + events: [{ + title: eventName, + start: new Date() + }] + }); + var el = $('div .fc-event'); + var offsetBefore = el.offset(); + dump(offsetBefore); + var options = { + dx: 200, + dy: 0, + moves: 10, + handle: 'corner' + }; + el.simulate('drag', options); + dump(el.offset()); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js b/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js new file mode 100644 index 0000000..dd2a6b7 --- /dev/null +++ b/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js @@ -0,0 +1,80 @@ +'use strict'; +describe('allDaySlots:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when allDaySlots is not set', function() { + describe('in agendaWeek', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaWeek' + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(1); + }); + }); + describe('in agendaDay', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaDay' + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(1); + }); + }); + }); + + describe('when allDaySlots is set true', function() { + describe('in agendaWeek', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaWeek', + allDaySlot: true + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(1); + }); + }); + describe('in agendaDay', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaDay', + allDaySlot: true + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(1); + }); + }); + }); + + describe('when allDaySlots is set false', function() { + describe('in agendaWeek', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaWeek', + allDaySlot: false + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(0); + }); + }); + describe('in agendaDay', function() { + it('should default to having an allDaySlots table', function() { + var options = { + defaultView: 'agendaDay', + allDaySlot: false + }; + $('#cal').fullCalendar(options); + var allDaySlotCount = $('table.fc-agenda-allday').length; + expect(allDaySlotCount).toEqual(0); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDayText.js b/specs/fullCalendarSpecs-AgendaOptions-allDayText.js new file mode 100644 index 0000000..0b80f83 --- /dev/null +++ b/specs/fullCalendarSpecs-AgendaOptions-allDayText.js @@ -0,0 +1,81 @@ +'use strict'; +describe('allDayText:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when allDaySlots is not set', function() { + describe('in agendaWeek', function() { + it('should default allDayText to using \'all-day\'', function() { + var options = { + defaultView: 'agendaWeek' + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('all-day'); + }); + }); + describe('in agendaDay', function() { + it('should default allDayText to using \'all-day\'', function() { + var options = { + defaultView: 'agendaDay' + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('all-day'); + }); + }); + }); + + describe('when allDaySlots is set true', function() { + describe('in agendaWeek', function() { + it('should default allDayText to using \'all-day\'', function() { + var options = { + defaultView: 'agendaWeek', + allDaySlot: true + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('all-day'); + }); + }); + describe('in agendaDay', function() { + it('should default allDayText to using \'all-day\'', function() { + var options = { + defaultView: 'agendaDay', + allDaySlot: true + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('all-day'); + }); + }); + }); + + describe('when allDaySlots is set true and allDayText is specified', function() { + describe('in agendaWeek', function() { + it('should show specified all day text', function() { + var options = { + defaultView: 'agendaWeek', + allDaySlot: true, + allDayText: 'axis-phosy' + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('axis-phosy'); + }); + }); + describe('in agendaDay', function() { + it('should show specified all day text', function() { + var options = { + defaultView: 'agendaDay', + allDayText: 'axis-phosy' + }; + $('#cal').fullCalendar(options); + var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text(); + expect(allDayText).toEqual('axis-phosy'); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-AgendaOptions-minTime.js b/specs/fullCalendarSpecs-AgendaOptions-minTime.js new file mode 100644 index 0000000..55b0080 --- /dev/null +++ b/specs/fullCalendarSpecs-AgendaOptions-minTime.js @@ -0,0 +1,132 @@ +'use strict'; +describe('minTime', function() { + + beforeEach(function() { + affix('#cal'); + }); + + var numToStringConverter = function(timeIn) { + var time = (timeIn % 12); + if ($.inArray(timeIn, [0, 12]) != -1) { + time = 12; + } + var amPm = 'am'; + if (timeIn > 11) { + amPm = 'pm'; + } + return time + 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-slot0 th').text(); + expect(firstSlotText).toEqual('12am'); + }); + }); + + describe('in agendaDay', function() { + it('should start at 12am', function() { + var options = { + defaultView: 'agendaWeek' + }; + $('#cal').fullCalendar(options); + var firstSlotText = $('.fc-slot0 th').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, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]; + + describe('in agendaWeek', function() { + beforeEach(function() { + affix('#cal2'); + }); + hourNumbers.forEach(function(minTimeIn) { + it('should start at ' + minTimeIn, function() { + var options = { + defaultView: 'agendaWeek', + minTime: minTimeIn + }; + $('#cal2').fullCalendar(options); + var firstSlotText = $('.fc-slot0 th').text(); + var expected = numToStringConverter(minTimeIn); + expect(firstSlotText).toEqual(expected); + }); + }); + }); + + describe('in agendaDay', function() { + beforeEach(function() { + affix('#cal2'); + }); + hourNumbers.forEach(function(minTimeIn) { + it('should start at ' + minTimeIn, function() { + var options = { + defaultView: 'agendaWeek', + minTime: minTimeIn + }; + $('#cal2').fullCalendar(options); + var firstSlotText = $('.fc-slot0 th').text(); + var expected = numToStringConverter(minTimeIn); + 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, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]; + + describe('in agendaWeek', function() { + beforeEach(function() { + affix('#cal2'); + }); + hourNumbers.forEach(function(minTimeIn) { + it('should start at ' + minTimeIn + 0.12, function() { + var options = { + defaultView: 'agendaWeek', + minTime: minTimeIn + 0.12 + }; + $('#cal2').fullCalendar(options); + var firstSlotElement = $('.fc-slot0')[0]; + var secondSlotElement = $('.fc-slot1')[0]; + var thirdSlotElement = $('.fc-slot2')[0]; + expect(firstSlotElement).toHaveClass('fc-minor'); + expect(secondSlotElement).toHaveClass('fc-minor'); + expect(thirdSlotElement).toHaveClass('fc-minor'); + }); + }); + }); + + describe('in agendaDay', function() { + beforeEach(function() { + affix('#cal2'); + }); + hourNumbers.forEach(function(minTimeIn) { + it('should start at ' + minTimeIn + 0.12, function() { + var options = { + defaultView: 'agendaWeek', + minTime: minTimeIn + 0.12 + }; + $('#cal2').fullCalendar(options); + var firstSlotElement = $('.fc-slot0')[0]; + var secondSlotElement = $('.fc-slot1')[0]; + var thirdSlotElement = $('.fc-slot2')[0]; + expect(firstSlotElement).toHaveClass('fc-minor'); + expect(secondSlotElement).toHaveClass('fc-minor'); + expect(thirdSlotElement).toHaveClass('fc-minor'); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js b/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js new file mode 100644 index 0000000..5775ba2 --- /dev/null +++ b/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js @@ -0,0 +1,96 @@ +'use strict'; +describe('slotMinutes:', function() { + + var minutesInADay = 1440; + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using the default Settings', function() { + describe('in agendaWeek', function() { + it('should have slots 1440/30 slots', function() { + var options = { + defaultView: 'agendaWeek' + }; + $('#cal').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + expect(slotCount).toEqual(Math.ceil(minutesInADay / 30)); + }); + }); + describe('in agendaDay', function() { + it('should have slots 1440/30 slots', function() { + var options = { + defaultView: 'agendaDay' + }; + $('#cal').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + expect(slotCount).toEqual(Math.ceil(minutesInADay / 30)); + }); + }); + }); + + describe('when slotMinutes is set to 30', function() { + describe('in agendaWeek', function() { + it('should have slots 1440/30 slots', function() { + var options = { + defaultView: 'agendaWeek' + }; + $('#cal').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + expect(slotCount).toEqual(Math.ceil(minutesInADay / 30)); + }); + }); + describe('in agendaDay', function() { + it('should have slots 1440/30 slots', function() { + var options = { + defaultView: 'agendaDay' + }; + $('#cal').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + expect(slotCount).toEqual(Math.ceil(minutesInADay / 30)); + }); + }); + }); + + describe('when slotMinutes is set to a series of times', function() { + + var slotMinutesList = [10, 12, 15, 17, 20, 30, 35, 45, 60, 62, 120, 300]; + + describe('in agendaWeek', function() { + beforeEach(function() { + affix('#cal2'); + }); + slotMinutesList.forEach(function(slotMinutesIn) { + it('should have slots 1440/x slots', function() { + var options = { + defaultView: 'agendaWeek', + slotMinutes: slotMinutesIn + }; + $('#cal2').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + var expected = Math.ceil(minutesInADay / slotMinutesIn); + expect(slotCount).toEqual(expected); + }); + }); + }); + + describe('in agendaDay', function() { + beforeEach(function() { + affix('#cal2'); + }); + slotMinutesList.forEach(function(slotMinutesIn) { + it('should have slots 1440/x slots', function() { + var options = { + defaultView: 'agendaWeek', + slotMinutes: slotMinutesIn + }; + $('#cal2').fullCalendar(options); + var slotCount = $('.fc-agenda-slots tr').length; + var expected = Math.ceil(minutesInADay / slotMinutesIn); + expect(slotCount).toEqual(expected); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-aspectRatio.js b/specs/fullCalendarSpecs-options-aspectRatio.js new file mode 100644 index 0000000..c5bc8bb --- /dev/null +++ b/specs/fullCalendarSpecs-options-aspectRatio.js @@ -0,0 +1,140 @@ +'use strict'; +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-content').height(); + expect(height).toEqual(500); + }); + it('fc-content should have width of div', function() { + var width = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width sizes very close to ratio of 2', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width sizes very close to ratio of 2', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width ratio to 0.5', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width ratio to 0.5', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width ratio to 0.5', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').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-content').width(); + expect(width).toEqual(1000); + }); + it('should set the height to width ratio to 0.5', function() { + var width = $('.fc-content').width(); + var height = $('.fc-content').height(); + var pxHeightPerCharacter = 22; + var defaultWeeksInCal = 7; + expect(height).toEqual(pxHeightPerCharacter * defaultWeeksInCal) + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-contentHeight.js b/specs/fullCalendarSpecs-options-contentHeight.js new file mode 100644 index 0000000..ac7ae9b --- /dev/null +++ b/specs/fullCalendarSpecs-options-contentHeight.js @@ -0,0 +1,49 @@ +'use strict'; +describe('contentHeight:', function() { + + beforeEach(function() { + affix('#cal'); + $('#cal').width(900); + }); + + describe('when the default options are used', function() { + it('should set the height', function() { + $('#cal').width(1350); + $('#cal').fullCalendar(); + var height = $('.fc-content').height(); + expect(height).toEqual(1000); + }); + }); + + describe('when the content height is set', function() { + it('should set the content height', function() { + $('#cal').fullCalendar({ + contentHeight: 1000 + }); + var height = $('.fc-content').height(); + expect(height).toEqual(1000); + }); + it('should not change the container width', function() { + $('#cal').fullCalendar({ + contentHeight: 1000 + }); + var width = $('#cal').width(); + expect(width).toEqual(900); + }); + }); + + describe('when the content height setter is used', function() { + it('should set the content height', function() { + $('#cal').fullCalendar(); + $('#cal').fullCalendar('option', 'contentHeight', 1137); + var height = $('.fc-content').height(); + expect(height).toEqual(1137); + }); + it('should not change the container width', function() { + $('#cal').fullCalendar(); + $('#cal').fullCalendar('option', 'contentHeight', 1137); + var width = $('#cal').width(); + expect(width).toEqual(900); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-firstDay.js b/specs/fullCalendarSpecs-options-firstDay.js new file mode 100644 index 0000000..52134b6 --- /dev/null +++ b/specs/fullCalendarSpecs-options-firstDay.js @@ -0,0 +1,166 @@ +describe('First Day : ', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using default settings', function() { + beforeEach(function() { + $('#cal').fullCalendar(); + }); + it('should make Sunday the first day of the week', function() { + var dayFirst = $('.fc-day-header')[0]; + expect(dayFirst).toHaveClass('fc-sun'); + }); + }); + + describe('when setting firstDay to 0', function() { + beforeEach(function() { + var options = { + firstDay: 0 + }; + $('#cal').fullCalendar(options); + }); + it('should make Sunday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-sun'); + expect(daysOfWeek[1]).toHaveClass('fc-mon'); + expect(daysOfWeek[2]).toHaveClass('fc-tue'); + expect(daysOfWeek[3]).toHaveClass('fc-wed'); + expect(daysOfWeek[4]).toHaveClass('fc-thu'); + expect(daysOfWeek[5]).toHaveClass('fc-fri'); + expect(daysOfWeek[6]).toHaveClass('fc-sat'); + }); + }); + + describe('when setting firstDay to 1', function() { + beforeEach(function() { + var options = { + firstDay: 1 + }; + $('#cal').fullCalendar(options); + }); + it('should make Monday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-mon'); + expect(daysOfWeek[1]).toHaveClass('fc-tue'); + expect(daysOfWeek[2]).toHaveClass('fc-wed'); + expect(daysOfWeek[3]).toHaveClass('fc-thu'); + expect(daysOfWeek[4]).toHaveClass('fc-fri'); + expect(daysOfWeek[5]).toHaveClass('fc-sat'); + expect(daysOfWeek[6]).toHaveClass('fc-sun'); + }); + }); + + describe('when setting firstDay to 2', function() { + beforeEach(function() { + var options = { + firstDay: 2 + }; + $('#cal').fullCalendar(options); + }); + it('should make Tuesday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-tue'); + expect(daysOfWeek[1]).toHaveClass('fc-wed'); + expect(daysOfWeek[2]).toHaveClass('fc-thu'); + expect(daysOfWeek[3]).toHaveClass('fc-fri'); + expect(daysOfWeek[4]).toHaveClass('fc-sat'); + expect(daysOfWeek[5]).toHaveClass('fc-sun'); + expect(daysOfWeek[6]).toHaveClass('fc-mon'); + }); + }); + + describe('when setting firstDay to 3', function() { + beforeEach(function() { + var options = { + firstDay: 3 + }; + $('#cal').fullCalendar(options); + }); + it('should make Wednesday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-wed'); + expect(daysOfWeek[1]).toHaveClass('fc-thu'); + expect(daysOfWeek[2]).toHaveClass('fc-fri'); + expect(daysOfWeek[3]).toHaveClass('fc-sat'); + expect(daysOfWeek[4]).toHaveClass('fc-sun'); + expect(daysOfWeek[5]).toHaveClass('fc-mon'); + expect(daysOfWeek[6]).toHaveClass('fc-tue'); + }); + }); + + describe('when setting firstDay to 4', function() { + beforeEach(function() { + var options = { + firstDay: 4 + }; + $('#cal').fullCalendar(options); + }); + it('should make Thursday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-thu'); + expect(daysOfWeek[1]).toHaveClass('fc-fri'); + expect(daysOfWeek[2]).toHaveClass('fc-sat'); + expect(daysOfWeek[3]).toHaveClass('fc-sun'); + expect(daysOfWeek[4]).toHaveClass('fc-mon'); + expect(daysOfWeek[5]).toHaveClass('fc-tue'); + expect(daysOfWeek[6]).toHaveClass('fc-wed'); + }); + }); + + describe('when setting firstDay to 5', function() { + beforeEach(function() { + var options = { + firstDay: 5 + }; + $('#cal').fullCalendar(options); + }); + it('should make Friday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-fri'); + expect(daysOfWeek[1]).toHaveClass('fc-sat'); + expect(daysOfWeek[2]).toHaveClass('fc-sun'); + expect(daysOfWeek[3]).toHaveClass('fc-mon'); + expect(daysOfWeek[4]).toHaveClass('fc-tue'); + expect(daysOfWeek[5]).toHaveClass('fc-wed'); + expect(daysOfWeek[6]).toHaveClass('fc-thu'); + }); + }); + + describe('when setting firstDay to 6', function() { + beforeEach(function() { + var options = { + firstDay: 6 + }; + $('#cal').fullCalendar(options); + }); + it('should make Saturday the first day of the week', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-sat'); + expect(daysOfWeek[1]).toHaveClass('fc-sun'); + expect(daysOfWeek[2]).toHaveClass('fc-mon'); + expect(daysOfWeek[3]).toHaveClass('fc-tue'); + expect(daysOfWeek[4]).toHaveClass('fc-wed'); + expect(daysOfWeek[5]).toHaveClass('fc-thu'); + expect(daysOfWeek[6]).toHaveClass('fc-fri'); + }); + }); + + describe('when new firstDay options are set', function() { + it('should change the first day of the week', function() { + var options = { + firstDay: 1 + }; + $('#cal').fullCalendar(options); + var firstDayBeforeChange = $('.fc-day-header')[0]; + var newOptions = { + firstDay: 4 + }; + $('#cal').fullCalendar(newOptions); + var firstDayAfterChange = $('.fc-day-header')[0]; + expect(firstDayBeforeChange).toHaveClass('fc-mon'); + expect(firstDayAfterChange).toHaveClass('fc-thu'); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-handleWindowResize.js b/specs/fullCalendarSpecs-options-handleWindowResize.js new file mode 100644 index 0000000..80c088c --- /dev/null +++ b/specs/fullCalendarSpecs-options-handleWindowResize.js @@ -0,0 +1,19 @@ +'use strict'; +describe('handleWindowResize:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('When default is used, should fire resize event', function() { + it('should fire resize', function() { + var resized = 0; + $('#cal').fullCalendar({ + windowResize: function(view) { + resized++; + } + }); + expect(resized).toEqual(1); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-header.js b/specs/fullCalendarSpecs-options-header.js new file mode 100644 index 0000000..e99d92a --- /dev/null +++ b/specs/fullCalendarSpecs-options-header.js @@ -0,0 +1,79 @@ +'use strict'; +describe('header Testing', function() { + + beforeEach(function() { + affix('#calendar'); + }); + + describe('when using default header options', function() { + it('should have title as default on left', function() { + $('#calendar').fullCalendar(); + var headr = $('#calendar > table.fc-header .fc-header-left > span')[0]; + expect(headr).toHaveClass('fc-header-title'); + }); + it('should have empty center', function() { + $('#calendar').fullCalendar(); + var cntr = $('#calendar > table.fc-header .fc-header-center')[0]; + expect(cntr).toBeEmpty(); + }); + it('should have right with today|space|left|right', function() { + $('#calendar').fullCalendar(); + var td = $('#calendar > table.fc-header .fc-header-right > span')[0]; + var sp = $('#calendar > table.fc-header .fc-header-right > span')[1]; + var lft = $('#calendar > table.fc-header .fc-header-right > span')[2]; + var rt = $('#calendar > table.fc-header .fc-header-right > span')[3]; + expect(td).toHaveClass('fc-button-today'); + expect(sp).toHaveClass('fc-header-space'); + expect(lft).toHaveClass('fc-button-prev'); + expect(rt).toHaveClass('fc-button-next'); + }); + }); + + describe('when supplying header options', function() { + beforeEach(function() { + var options = { + header: { + left: 'next,prev', + center: 'prevYear today nextYear agendaView,dayView', + right: 'title' + } + }; + $('#calendar').fullCalendar(options); + }); + it('should have title on the right', function() { + var item = $('#calendar > table.fc-header .fc-header-right > span')[0]; + expect(item).toHaveClass('fc-header-title'); + }); + it('should have next|prev on left', function() { + var nxt = $('#calendar > table.fc-header .fc-header-left > span')[0]; + var prv = $('#calendar > table.fc-header .fc-header-left > span')[1]; + expect(nxt).toHaveClass('fc-button-next'); + expect(prv).toHaveClass('fc-button-prev'); + }); + it('should have prevYear|space|today|space|nextYear in center', function() { + var py = $('#calendar > table.fc-header .fc-header-center > span')[0]; + var sp1 = $('#calendar > table.fc-header .fc-header-center > span')[1]; + var td = $('#calendar > table.fc-header .fc-header-center > span')[2]; + var sp2 = $('#calendar > table.fc-header .fc-header-center > span')[3]; + var ny = $('#calendar > table.fc-header .fc-header-center > span')[4]; + expect(py).toHaveClass('fc-button-prevYear'); + expect(sp1).toHaveClass('fc-header-space'); + expect(td).toHaveClass('fc-button-today'); + expect(sp2).toHaveClass('fc-header-space'); + expect(ny).toHaveClass('fc-button-nextYear'); + }); + }); + + describe('when setting header to false', function() { + beforeEach(function() { + var options = { + header: false + }; + $('#calendar').fullCalendar(options); + }) + it('should not have header table', function() { + var headerTableCount = $('table.fc-header').length; + expect(headerTableCount).toEqual(0); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-headerDateClick.js b/specs/fullCalendarSpecs-options-headerDateClick.js new file mode 100644 index 0000000..cfe2606 --- /dev/null +++ b/specs/fullCalendarSpecs-options-headerDateClick.js @@ -0,0 +1,60 @@ +'use strict'; +describe('when header options set with next|prev|prevYear|nextYear|today', function() { + + beforeEach(function() { + affix('#calendar'); + var options = { + header: { + left: 'next,prev,prevYear,nextYear today', + center: '', + right: 'title' + } + }; + $('#calendar').fullCalendar(options); + }); + + describe('and click next', function() { + it('should change view to next month', function() { + $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('.fc-button-next').simulate('click'); + var newDate = $('#calendar').fullCalendar('getDate'); + expect(newDate).toEqual(new Date(2010, 2, 1)); + }); + }); + + describe('and click prev', function() { + it('should change view to prev month', function() { + $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('.fc-button-prev').simulate('click'); + var newDate = $('#calendar').fullCalendar('getDate'); + expect(newDate).toEqual(new Date(2009, 12, 1)); + }); + }); + + describe('and click prevYear', function() { + it('should change view to prev month', function() { + $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('.fc-button-prevYear').simulate('click'); + var newDate = $('#calendar').fullCalendar('getDate'); + expect(newDate).toEqual(new Date(2009, 1, 1)); + }); + }); + + describe('and click nextYear', function() { + it('should change view to prev month', function() { + $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('.fc-button-nextYear').simulate('click'); + var newDate = $('#calendar').fullCalendar('getDate'); + expect(newDate).toEqual(new Date(2011, 1, 1)); + }); + }); + + describe('and click today', function() { + it('should change view to prev month', function() { + $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('.fc-button-today').simulate('click'); + var newDate = $('#calendar').fullCalendar('getDate'); + expect(newDate.toDateString()).toEqual(new Date().toDateString()); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-height.js b/specs/fullCalendarSpecs-options-height.js new file mode 100644 index 0000000..2b0e183 --- /dev/null +++ b/specs/fullCalendarSpecs-options-height.js @@ -0,0 +1,49 @@ +'use strict'; +describe('height:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using default height', function() { + it('should use default height based on default aspect ratio of 1:35', function() { + $('#cal').width(1350); + $('#cal').fullCalendar(); + var height = $('.fc-content').height(); + expect(height).toEqual(1000); + }); + }); + + describe('when setting height with the setter', function() { + beforeEach(function() { + $('#cal').width(673); + $('#cal').fullCalendar(); + $('#cal').fullCalendar('option', 'height', 751); + }); + it('should not change the width of the block level container', function() { + var width = $('#cal').width(); + expect(width).toEqual(673); + }); + it('should set the size of the block level container to the height', function() { + var height = $('#cal').height(); + expect(height).toEqual(751); + }); + }); + + describe('when setting height at instantiation', function() { + beforeEach(function() { + $('#cal').width(673); + $('#cal').fullCalendar({ + height: 751 + }); + }); + it('should not change the width of the block level container', function() { + var width = $('#cal').width(); + expect(width).toEqual(673); + }); + it('should set the size of the block level container to the height', function() { + var height = $('#cal').height(); + expect(height).toEqual(751); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-hiddenDays.js b/specs/fullCalendarSpecs-options-hiddenDays.js new file mode 100644 index 0000000..a7351c6 --- /dev/null +++ b/specs/fullCalendarSpecs-options-hiddenDays.js @@ -0,0 +1,87 @@ +describe('hiddenDays:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using default', function() { + beforeEach(function() { + $('#cal').fullCalendar(); + }); + it('should show 7 days of the week', function() { + var daysCount = $('.fc-day-header').length; + expect(daysCount).toEqual(7); + }); + }); + + describe('when setting an empty hiddenDays', function() { + beforeEach(function() { + $('#cal').fullCalendar({ + hiddenDays: [] + }); + }); + it('should return 7 days of the week', function() { + var daysCount = $('.fc-day-header').length; + expect(daysCount).toEqual(7); + }); + }); + + describe('when setting hiddenDays with 1', function() { + beforeEach(function() { + $('#cal').fullCalendar({ + hiddenDays: [1] + }); + }); + it('should return 6 days', function() { + var daysCount = $('.fc-day-header').length; + expect(daysCount).toEqual(6); + }); + it('should return sun,tue,wed..sat days', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-sun'); + expect(daysOfWeek[1]).toHaveClass('fc-tue'); + expect(daysOfWeek[5]).toHaveClass('fc-sat'); + }); + it('should expect 7th day to be undefined', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[6]).toBeUndefined(); + }); + }); + + describe('when setting hiddenDays with 3,5', function() { + beforeEach(function() { + $('#cal').fullCalendar({ + hiddenDays: [3, 5] + }); + }); + it('should return 6 days', function() { + var daysCount = $('.fc-day-header').length; + expect(daysCount).toEqual(5); + }); + it('should return s,m,t,t,s ', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-sun'); + expect(daysOfWeek[1]).toHaveClass('fc-mon'); + expect(daysOfWeek[2]).toHaveClass('fc-tue'); + expect(daysOfWeek[3]).toHaveClass('fc-thu'); + expect(daysOfWeek[4]).toHaveClass('fc-sat'); + }); + it('should expect wed and fri be undefined', function() { + var fri = $('.fc-day-header.fc-fri')[0]; + var wed = $('.fc-day-header.fc-wed')[0]; + expect(fri).toBeUndefined(); + expect(wed).toBeUndefined(); + }); + }); + + describe('when setting all hiddenDays', function() { + it('should expect to throw an exception', function() { + var options = { + hiddenDays: [0, 1, 2, 3, 4, 5, 6] + }; + expect(function() { + $('#cal').fullCalendar(options); + }).toThrow('invalid hiddenDays'); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-isRTL.js b/specs/fullCalendarSpecs-options-isRTL.js new file mode 100644 index 0000000..67841bd --- /dev/null +++ b/specs/fullCalendarSpecs-options-isRTL.js @@ -0,0 +1,231 @@ +'use strict'; +describe('isRTL tests:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when setting l:prev c:today r:next settings with isRTL default', function() { + beforeEach(function() { + var options = { + header: { + left: 'prev', + center: 'today', + right: 'next' + } + }; + $('#cal').fullCalendar(options); + var cal = $('#cal'); + }); + it('should have prev in left', function() { + var fcHeaderLeft = $(cal).find('.fc-header-left')[0]; + expect(fcHeaderLeft).toContain('.fc-button-prev'); + }); + it('should have today in center', function() { + var fcHeaderCenter = $(cal).find('.fc-header-center')[0]; + expect(fcHeaderCenter).toContain('.fc-button-today'); + }); + it('should have next in right', function() { + var fcHeaderRight = $(cal).find('.fc-header-right')[0]; + expect(fcHeaderRight).toContain('.fc-button-next'); + }); + }); + + describe('when setting l:prev c:today r:next settings with isRTL false', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + header: { + left: 'prev', + center: 'today', + right: 'next' + }, + isRTL: false + }); + var cal = $('#cal'); + }); + it('should have prev in left', function() { + var fcHeaderLeft = $(cal).find('.fc-header-left')[0]; + expect(fcHeaderLeft).toContain('.fc-button-prev'); + }); + it('should have today in center', function() { + var fcHeaderCenter = $(cal).find('.fc-header-center')[0]; + expect(fcHeaderCenter).toContain('.fc-button-today'); + }); + it('should have next in right', function() { + var fcHeaderRight = $(cal).find('.fc-header-right')[0]; + expect(fcHeaderRight).toContain('.fc-button-next'); + }); + }); + + describe('when setting l:prev c:today r:next settings with isRTL true', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + header: { + left: 'prev', + center: 'today', + right: 'next' + }, + isRTL: true + }); + var cal = $('#cal'); + }); + it('should have prev in left', function() { + var fcHeaderLeft = $(cal).find('.fc-header-left')[0]; + expect(fcHeaderLeft).toContain('.fc-button-prev'); + }); + it('should have today in center', function() { + var fcHeaderCenter = $(cal).find('.fc-header-center')[0]; + expect(fcHeaderCenter).toContain('.fc-button-today'); + }); + it('should have next in right', function() { + var fcHeaderRight = $(cal).find('.fc-header-right')[0]; + expect(fcHeaderRight).toContain('.fc-button-next'); + }); + }); + + describe('when using default view (month)', function() { + + describe('using default isRTL', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar(); + var cal = $('#cal'); + }); + it('should have have days ordered sun to sat', function() { + var fc = $(cal).find('.fc-day-header'); + expect(fc[0]).toHaveClass('fc-sun'); + expect(fc[1]).toHaveClass('fc-mon'); + expect(fc[2]).toHaveClass('fc-tue'); + expect(fc[3]).toHaveClass('fc-wed'); + expect(fc[4]).toHaveClass('fc-thu'); + expect(fc[5]).toHaveClass('fc-fri'); + expect(fc[6]).toHaveClass('fc-sat'); + }); + }); + + describe('using default isRTL is set to false', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + isRTL: false + }); + var cal = $('#cal'); + }); + it('should have have days ordered sun to sat', function() { + var fc = $(cal).find('.fc-day-header'); + expect(fc[0]).toHaveClass('fc-sun'); + expect(fc[1]).toHaveClass('fc-mon'); + expect(fc[2]).toHaveClass('fc-tue'); + expect(fc[3]).toHaveClass('fc-wed'); + expect(fc[4]).toHaveClass('fc-thu'); + expect(fc[5]).toHaveClass('fc-fri'); + expect(fc[6]).toHaveClass('fc-sat'); + }); + }); + + describe('using default isRTL is set to false', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + isRTL: true + }); + var cal = $('#cal'); + }); + it('should have have days ordered back sat to sun', function() { + var fc = $(cal).find('.fc-day-header'); + expect(fc[6]).toHaveClass('fc-sun'); + expect(fc[5]).toHaveClass('fc-mon'); + expect(fc[4]).toHaveClass('fc-tue'); + expect(fc[3]).toHaveClass('fc-wed'); + expect(fc[2]).toHaveClass('fc-thu'); + expect(fc[1]).toHaveClass('fc-fri'); + expect(fc[0]).toHaveClass('fc-sat'); + }); + }); + }); + + describe('when using agendaWeek view', function() { + + describe('when using default isRTL', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + defaultView: 'agendaWeek' + }); + }); + it('should have have days ordered sun to sat', function() { + var fc = $(cal).find('.fc-agenda-days th'); + expect(fc[0]).toHaveClass('fc-agenda-axis'); + expect(fc[1]).toHaveClass('fc-sun'); + expect(fc[2]).toHaveClass('fc-mon'); + expect(fc[3]).toHaveClass('fc-tue'); + expect(fc[4]).toHaveClass('fc-wed'); + expect(fc[5]).toHaveClass('fc-thu'); + expect(fc[6]).toHaveClass('fc-fri'); + expect(fc[7]).toHaveClass('fc-sat'); + }); + }); + + describe('when using isRTL false', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + defaultView: 'agendaWeek', + isRTL: false + }); + }); + it('should have have days ordered sun to sat', function() { + var fc = $(cal).find('.fc-agenda-days th'); + expect(fc[0]).toHaveClass('fc-agenda-axis'); + expect(fc[1]).toHaveClass('fc-sun'); + expect(fc[2]).toHaveClass('fc-mon'); + expect(fc[3]).toHaveClass('fc-tue'); + expect(fc[4]).toHaveClass('fc-wed'); + expect(fc[5]).toHaveClass('fc-thu'); + expect(fc[6]).toHaveClass('fc-fri'); + expect(fc[7]).toHaveClass('fc-sat'); + }); + }); + + describe('when using isRTL true', function() { + beforeEach(function() { + var options = {}; + $('#cal').fullCalendar({ + defaultView: 'agendaWeek', + isRTL: true + }); + }); + it('should have have days ordered sun to sat', function() { + var fc = $(cal).find('.fc-agenda-days th'); + expect(fc[0]).toHaveClass('fc-agenda-axis'); + expect(fc[1]).toHaveClass('fc-sat'); + expect(fc[2]).toHaveClass('fc-fri'); + expect(fc[3]).toHaveClass('fc-thu'); + expect(fc[4]).toHaveClass('fc-wed'); + expect(fc[5]).toHaveClass('fc-tue'); + expect(fc[6]).toHaveClass('fc-mon'); + expect(fc[7]).toHaveClass('fc-sun'); + }); + }); + }); + + xdescribe('when using agendaWeek view', function() { + describe('and switching from isRTL false to true', function() { + beforeEach(function() { + $('#cal').fullCalendar({ + defaultView: 'agendaWeek', + isRTL: false + }); + }); + it('should result in sunday moving from first to last day', function() { + var fcDaysBefore = $(cal).find('.fc-agenda-days th'); + $('#cal').fullCalendar('isRTL', 'true'); + var fcDaysAfter = $(cal).find('.fc-agenda-days th'); + expect(fcDaysBefore[1]).toHaveClass('fc-sun'); + expect(fcDaysAfter[7]).toHaveCalss('fc-sun'); + }); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-weekMode.js b/specs/fullCalendarSpecs-options-weekMode.js new file mode 100644 index 0000000..5546906 --- /dev/null +++ b/specs/fullCalendarSpecs-options-weekMode.js @@ -0,0 +1,148 @@ +'use strict'; +describe('weekMode:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + // + // Remember gotoDate uses month base 0 + // + 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, 9); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should show 6 weeks for a 4 week month', function() { + $('#cal').fullCalendar('gotoDate', 2009, 2); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should show 6 weeks for a 6 week month', function() { + $('#cal').fullCalendar('gotoDate', 2013, 5); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should not change height whether 4,5 or weeks', function() { + $('#cal').fullCalendar('gotoDate', 2009, 1); + var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 9); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 5); + var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + 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, 9); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should show 6 weeks for a 4 week month', function() { + $('#cal').fullCalendar('gotoDate', 2009, 2); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should show 6 weeks for a 6 week month', function() { + $('#cal').fullCalendar('gotoDate', 2013, 5); + 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, 9); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(5); + }); + it('should show 4 weeks for a 4 week month', function() { + $('#cal').fullCalendar('gotoDate', 2009, 1); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(4); + }); + it('should show 6 weeks for a 6 week month', function() { + $('#cal').fullCalendar('gotoDate', 2013, 5); + 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, 9); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 5); + var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight); + }); + it('should reduce height when moving from 5 weeks to 6 weeks', function() { + $('#cal').fullCalendar('gotoDate', 2013, 5); + var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 9); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight); + }); + it('should increase height when moving from 5 weeks to 4 weeks', function() { + $('#cal').fullCalendar('gotoDate', 2013, 4); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2009, 1); + var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight); + }); + it('should reduce height when moving from 4 weeks to 5 weeks', function() { + $('#cal').fullCalendar('gotoDate', 2009, 1); + var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 4); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight); + }); + }); + + 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, 9); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(5); + }); + it('should show 4 weeks for a 4 week month', function() { + $('#cal').fullCalendar('gotoDate', 2009, 1); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(4); + }); + it('should show 6 weeks for a 6 week month', function() { + $('#cal').fullCalendar('gotoDate', 2013, 5); + var weekCount = $('.fc-week').length; + expect(weekCount).toEqual(6); + }); + it('should not change height whether 4,5 or weeks', function() { + $('#cal').fullCalendar('gotoDate', 2009, 1); + var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 9); + var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + $('#cal').fullCalendar('gotoDate', 2013, 5); + var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); + expect(fourWeekHeight).toEqual(fiveWeekHeight); + expect(fiveWeekHeight).toEqual(sixWeekHeight); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-weekNumberCalculation.js b/specs/fullCalendarSpecs-options-weekNumberCalculation.js new file mode 100644 index 0000000..a29cc83 --- /dev/null +++ b/specs/fullCalendarSpecs-options-weekNumberCalculation.js @@ -0,0 +1,36 @@ +'use strict'; +describe('weekNumberCalculation:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using the default', function() { + it('should return iso standard', function() { + $('#cal').fullCalendar({ + editable: true, + weekNumbers: true + }); + $('#cal').fullCalendar('gotoDate', 2013, 10, 17); + var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text()); + expect(weekNum).toEqual(43); + }); + }); + + describe('when using a defined weekNumber calculation', function() { + it('should return the calculated number', function() { + $('#cal').fullCalendar({ + editable: true, + weekNumbers: true, + weekNumberCalculation: myWeekNumber + }); + $('#cal').fullCalendar('gotoDate', 2013, 10, 17); + var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text()); + expect(weekNum).toEqual(4); + }); + }); + + var myWeekNumber = function(someDate) { + return 4; + }; +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-weekNumbers.js b/specs/fullCalendarSpecs-options-weekNumbers.js new file mode 100644 index 0000000..4911efa --- /dev/null +++ b/specs/fullCalendarSpecs-options-weekNumbers.js @@ -0,0 +1,38 @@ +'use strict'; +describe('weekNumbers:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using default weekNumbers in default view', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar(); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + + describe('when setting weekNumbers to false in default view', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + weekNumbers: false + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + + describe('when setting weekNumbers to true in default view', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + weekNumbers: true + }); + $('#cal').fullCalendar('gotoDate', 2013, 10); + var weekNumbersCount = $('.fc-week-number').length; + // 1 row is header + // 6 rows are week numbers + expect(weekNumbersCount).toEqual(7); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-weekends.js b/specs/fullCalendarSpecs-options-weekends.js new file mode 100644 index 0000000..b8f8dbf --- /dev/null +++ b/specs/fullCalendarSpecs-options-weekends.js @@ -0,0 +1,31 @@ +'use strict'; +describe('when weekends option is set', function() { + + beforeEach(function() { + affix('#calendar'); + var cal = $('#calendar'); + }) + + it('should show sat and sun if true', function() { + var options = { + weekends: true + }; + $('#calendar').fullCalendar(options); + var sun = $('.fc-day-header.fc-sun')[0]; + var sat = $('.fc-day-header.fc-sun')[0]; + expect(sun).toBeDefined(); + expect(sat).toBeDefined(); + }); + + it('should not show sat and sun if false', function() { + var options = { + weekends: false + }; + $('#calendar').fullCalendar(options); + var sun = $('.fc-day-header.fc-sun')[0]; + var sat = $('.fc-day-header.fc-sun')[0]; + expect(sun).not.toBeDefined(); + expect(sat).not.toBeDefined(); + }); + +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js b/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js new file mode 100644 index 0000000..835cc88 --- /dev/null +++ b/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js @@ -0,0 +1,26 @@ +describe('First Day : ', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when first day is set to mon and isRTL is true', function() { + beforeEach(function() { + var options = { + firstDay: 2, + isRTL: true + }; + $('#cal').fullCalendar(options); + }); + it('should put days mon, sun, sat ...', function() { + var daysOfWeek = $('.fc-day-header'); + expect(daysOfWeek[0]).toHaveClass('fc-mon'); + expect(daysOfWeek[1]).toHaveClass('fc-sun'); + expect(daysOfWeek[2]).toHaveClass('fc-sat'); + expect(daysOfWeek[3]).toHaveClass('fc-fri'); + expect(daysOfWeek[4]).toHaveClass('fc-thu'); + expect(daysOfWeek[5]).toHaveClass('fc-wed'); + expect(daysOfWeek[6]).toHaveClass('fc-tue'); + }); + }); +}); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js b/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js new file mode 100644 index 0000000..5054c93 --- /dev/null +++ b/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js @@ -0,0 +1,141 @@ +'use strict'; +describe('weekNumbers-defaultView:', function() { + + beforeEach(function() { + affix('#cal'); + }); + + describe('when using basicWeek ', function() { + describe('with default weekNumbers ', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicWeek' + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to false', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicWeek', + weekNumbers: false + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to true ', function() { + it('should display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicWeek', + weekNumbers: true + }); + var weekNumbersCount = $('.fc-week-number').length; + // 1 row is header + // 1 row is actual week number + expect(weekNumbersCount).toEqual(2); + }); + }); + }); + + describe('when using basicDay', function() { + describe('with default weekNumbers ', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicDay' + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to false', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicDay', + weekNumbers: false + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to true ', function() { + it('should display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'basicDay', + weekNumbers: true + }); + var weekNumbersCount = $('.fc-week-number').length; + // 1 row is header + // 1 row is actual week number + expect(weekNumbersCount).toEqual(2); + }); + }); + }); + + describe('when using agendaWeek', function() { + describe('with default weekNumbers ', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaWeek' + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to false', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaWeek', + weekNumbers: false + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to true ', function() { + it('should display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaWeek', + weekNumbers: true + }); + var weekNumbersCount = $('.fc-week-number').length; + // 1 row is axis + expect(weekNumbersCount).toEqual(1); + }); + }); + }); + + describe('when using agendaDay', function() { + describe('with default weekNumbers ', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaDay' + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to false', function() { + it('should not display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaDay', + weekNumbers: false + }); + var weekNumbersCount = $('.fc-week-number').length; + expect(weekNumbersCount).toEqual(0); + }); + }); + describe('with weekNumbers to true ', function() { + it('should display weekNumbers', function() { + $('#cal').fullCalendar({ + defaultView: 'agendaDay', + weekNumbers: true + }); + var weekNumbersCount = $('.fc-week-number').length; + // 1 row is axis + expect(weekNumbersCount).toEqual(1); + }); + }); + }); +}); \ No newline at end of file diff --git a/tests/base.css b/tests/base.css new file mode 100644 index 0000000..6370e1e --- /dev/null +++ b/tests/base.css @@ -0,0 +1,12 @@ + +body { + margin-top: 40px; + text-align: center; + font-size: 13px; + font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif; +} + +#calendar { + width: 900px; + margin: 0 auto; +} From 0dc2906b4ec27962d0359e36f0fafa05facf4dd8 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sat, 25 Jan 2014 19:58:26 -0800 Subject: [PATCH 02/14] slight tweaks to testing framework code --- karma.conf.IntegrationTests.js | 7 ++----- specs/fullCalendar.js | 10 +++++----- ...CalendarSpecs-AgendaOptions-allDaySlots.js | 4 ++-- ...lCalendarSpecs-AgendaOptions-allDayText.js | 4 ++-- ...fullCalendarSpecs-AgendaOptions-minTime.js | 4 ++-- ...CalendarSpecs-AgendaOptions-slotMinutes.js | 6 +++--- .../fullCalendarSpecs-options-aspectRatio.js | 8 ++++---- ...fullCalendarSpecs-options-contentHeight.js | 4 ++-- specs/fullCalendarSpecs-options-firstDay.js | 3 ++- ...alendarSpecs-options-handleWindowResize.js | 4 ++-- specs/fullCalendarSpecs-options-header.js | 4 ++-- ...llCalendarSpecs-options-headerDateClick.js | 2 +- specs/fullCalendarSpecs-options-height.js | 4 ++-- specs/fullCalendarSpecs-options-hiddenDays.js | 3 ++- specs/fullCalendarSpecs-options-isRTL.js | 4 ++-- specs/fullCalendarSpecs-options-weekMode.js | 4 ++-- ...ndarSpecs-options-weekNumberCalculation.js | 12 +++++------ .../fullCalendarSpecs-options-weekNumbers.js | 4 ++-- specs/fullCalendarSpecs-options-weekends.js | 2 +- ...pecs-optionsCombinations-firstDay-isRTL.js | 2 +- ...onsCombinations-weekNumbers-defaultView.js | 20 +++++++++---------- 21 files changed, 56 insertions(+), 59 deletions(-) diff --git a/karma.conf.IntegrationTests.js b/karma.conf.IntegrationTests.js index fcec513..a238813 100644 --- a/karma.conf.IntegrationTests.js +++ b/karma.conf.IntegrationTests.js @@ -1,5 +1,4 @@ -// Karma configuration -// Generated on Wed Sep 18 2013 21:29:48 GMT+0100 (GMT Daylight Time) + module.exports = function(config) { config.set({ @@ -15,11 +14,9 @@ module.exports = function(config) { { pattern: './lib/jquery-simulate/*.js', watched: false }, { pattern: './lib/jasmine-jquery/*.js', watched: false }, { pattern: './lib/jquery-ui/ui/jquery-ui.js', watched: false }, - { pattern: './lib/jquery-ui/ui/jquery.ui.draggable.js', watched: false }, { pattern: './lib/jasmine-fixture/*.js', watched: false }, './build/out/fullcalendar.js', './build/out/fullcalendar.css', - './build/out/fullcalendar.print.css', './specs/fullCalendar*.js' ], @@ -51,7 +48,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: [ 'PhantomJS' ], + //browsers: [ 'PhantomJS' ], // If browser does not capture in given timeout [ms], kill it captureTimeout: 60000, diff --git a/specs/fullCalendar.js b/specs/fullCalendar.js index 520e9ac..9a55625 100644 --- a/specs/fullCalendar.js +++ b/specs/fullCalendar.js @@ -1,5 +1,5 @@ -'use strict'; -describe('fullCalendar(Integration) :', function() { + +describe('fullCalendar(Integration)', function() { beforeEach(function() { affix('#calendar'); @@ -11,17 +11,17 @@ describe('fullCalendar(Integration) :', function() { $('#calendar').fullCalendar(); }); - it('should contain a table fc-header ', function() { + it('should contain a table fc-header', function() { var header = $('#calendar > table.fc-header'); expect(header[0]).not.toBeUndefined(); }); - it('should contain a div fc-content ', function() { + it('should contain a div fc-content', function() { var content = ($('#calendar > div.fc-content')); expect(content[0]).not.toBeUndefined(); }); - it('should only contain 2 elements ', function() { + it('should only contain 2 elements', function() { var calenderNodeCount = $('#calendar >').length; expect(calenderNodeCount).toEqual(2); }); diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js b/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js index dd2a6b7..578209b 100644 --- a/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js +++ b/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js @@ -1,5 +1,5 @@ -'use strict'; -describe('allDaySlots:', function() { + +describe('allDaySlots', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDayText.js b/specs/fullCalendarSpecs-AgendaOptions-allDayText.js index 0b80f83..7c95d5a 100644 --- a/specs/fullCalendarSpecs-AgendaOptions-allDayText.js +++ b/specs/fullCalendarSpecs-AgendaOptions-allDayText.js @@ -1,5 +1,5 @@ -'use strict'; -describe('allDayText:', function() { + +describe('allDayText', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-AgendaOptions-minTime.js b/specs/fullCalendarSpecs-AgendaOptions-minTime.js index 55b0080..21f9e1b 100644 --- a/specs/fullCalendarSpecs-AgendaOptions-minTime.js +++ b/specs/fullCalendarSpecs-AgendaOptions-minTime.js @@ -1,4 +1,4 @@ -'use strict'; + describe('minTime', function() { beforeEach(function() { @@ -17,7 +17,7 @@ describe('minTime', function() { return time + amPm; }; - describe('when using the default Settings', function() { + describe('when using the default settings', function() { describe('in agendaWeek', function() { it('should start at 12am', function() { diff --git a/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js b/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js index 5775ba2..aad0c08 100644 --- a/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js +++ b/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js @@ -1,5 +1,5 @@ -'use strict'; -describe('slotMinutes:', function() { + +describe('slotMinutes', function() { var minutesInADay = 1440; @@ -7,7 +7,7 @@ describe('slotMinutes:', function() { affix('#cal'); }); - describe('when using the default Settings', function() { + describe('when using the default settings', function() { describe('in agendaWeek', function() { it('should have slots 1440/30 slots', function() { var options = { diff --git a/specs/fullCalendarSpecs-options-aspectRatio.js b/specs/fullCalendarSpecs-options-aspectRatio.js index c5bc8bb..9a15fe0 100644 --- a/specs/fullCalendarSpecs-options-aspectRatio.js +++ b/specs/fullCalendarSpecs-options-aspectRatio.js @@ -1,5 +1,5 @@ -'use strict'; -describe('aspectRatio:', function() { + +describe('aspectRatio', function() { beforeEach(function() { affix('#cal'); @@ -60,7 +60,7 @@ describe('aspectRatio:', function() { }); }); - describe('to less than 0.5 ', function() { + describe('to less than 0.5', function() { beforeEach(function() { $('#cal').width(1000) $('#cal').fullCalendar({ @@ -79,7 +79,7 @@ describe('aspectRatio:', function() { }); }); - describe('to negative ', function() { + describe('to negative', function() { beforeEach(function() { $('#cal').width(1000) $('#cal').fullCalendar({ diff --git a/specs/fullCalendarSpecs-options-contentHeight.js b/specs/fullCalendarSpecs-options-contentHeight.js index ac7ae9b..590b399 100644 --- a/specs/fullCalendarSpecs-options-contentHeight.js +++ b/specs/fullCalendarSpecs-options-contentHeight.js @@ -1,5 +1,5 @@ -'use strict'; -describe('contentHeight:', function() { + +describe('contentHeight', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-firstDay.js b/specs/fullCalendarSpecs-options-firstDay.js index 52134b6..b617468 100644 --- a/specs/fullCalendarSpecs-options-firstDay.js +++ b/specs/fullCalendarSpecs-options-firstDay.js @@ -1,4 +1,5 @@ -describe('First Day : ', function() { + +describe('First Day', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-handleWindowResize.js b/specs/fullCalendarSpecs-options-handleWindowResize.js index 80c088c..bc050c4 100644 --- a/specs/fullCalendarSpecs-options-handleWindowResize.js +++ b/specs/fullCalendarSpecs-options-handleWindowResize.js @@ -1,5 +1,5 @@ -'use strict'; -describe('handleWindowResize:', function() { + +describe('handleWindowResize', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-header.js b/specs/fullCalendarSpecs-options-header.js index e99d92a..b88388a 100644 --- a/specs/fullCalendarSpecs-options-header.js +++ b/specs/fullCalendarSpecs-options-header.js @@ -1,5 +1,5 @@ -'use strict'; -describe('header Testing', function() { + +describe('header testing', function() { beforeEach(function() { affix('#calendar'); diff --git a/specs/fullCalendarSpecs-options-headerDateClick.js b/specs/fullCalendarSpecs-options-headerDateClick.js index cfe2606..b12b9b0 100644 --- a/specs/fullCalendarSpecs-options-headerDateClick.js +++ b/specs/fullCalendarSpecs-options-headerDateClick.js @@ -1,4 +1,4 @@ -'use strict'; + describe('when header options set with next|prev|prevYear|nextYear|today', function() { beforeEach(function() { diff --git a/specs/fullCalendarSpecs-options-height.js b/specs/fullCalendarSpecs-options-height.js index 2b0e183..620de1c 100644 --- a/specs/fullCalendarSpecs-options-height.js +++ b/specs/fullCalendarSpecs-options-height.js @@ -1,5 +1,5 @@ -'use strict'; -describe('height:', function() { + +describe('height', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-hiddenDays.js b/specs/fullCalendarSpecs-options-hiddenDays.js index a7351c6..3f52567 100644 --- a/specs/fullCalendarSpecs-options-hiddenDays.js +++ b/specs/fullCalendarSpecs-options-hiddenDays.js @@ -1,4 +1,5 @@ -describe('hiddenDays:', function() { + +describe('hiddenDays', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-isRTL.js b/specs/fullCalendarSpecs-options-isRTL.js index 67841bd..cfc2594 100644 --- a/specs/fullCalendarSpecs-options-isRTL.js +++ b/specs/fullCalendarSpecs-options-isRTL.js @@ -1,5 +1,5 @@ -'use strict'; -describe('isRTL tests:', function() { + +describe('isRTL tests', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-weekMode.js b/specs/fullCalendarSpecs-options-weekMode.js index 5546906..8e6f362 100644 --- a/specs/fullCalendarSpecs-options-weekMode.js +++ b/specs/fullCalendarSpecs-options-weekMode.js @@ -1,5 +1,5 @@ -'use strict'; -describe('weekMode:', function() { + +describe('weekMode', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-weekNumberCalculation.js b/specs/fullCalendarSpecs-options-weekNumberCalculation.js index a29cc83..ff3c49b 100644 --- a/specs/fullCalendarSpecs-options-weekNumberCalculation.js +++ b/specs/fullCalendarSpecs-options-weekNumberCalculation.js @@ -1,5 +1,5 @@ -'use strict'; -describe('weekNumberCalculation:', function() { + +describe('weekNumberCalculation', function() { beforeEach(function() { affix('#cal'); @@ -22,15 +22,13 @@ describe('weekNumberCalculation:', function() { $('#cal').fullCalendar({ editable: true, weekNumbers: true, - weekNumberCalculation: myWeekNumber + weekNumberCalculation: function() { + return 4; + } }); $('#cal').fullCalendar('gotoDate', 2013, 10, 17); var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text()); expect(weekNum).toEqual(4); }); }); - - var myWeekNumber = function(someDate) { - return 4; - }; }); \ No newline at end of file diff --git a/specs/fullCalendarSpecs-options-weekNumbers.js b/specs/fullCalendarSpecs-options-weekNumbers.js index 4911efa..e95f9e9 100644 --- a/specs/fullCalendarSpecs-options-weekNumbers.js +++ b/specs/fullCalendarSpecs-options-weekNumbers.js @@ -1,5 +1,5 @@ -'use strict'; -describe('weekNumbers:', function() { + +describe('weekNumbers', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-options-weekends.js b/specs/fullCalendarSpecs-options-weekends.js index b8f8dbf..91f9522 100644 --- a/specs/fullCalendarSpecs-options-weekends.js +++ b/specs/fullCalendarSpecs-options-weekends.js @@ -1,4 +1,4 @@ -'use strict'; + describe('when weekends option is set', function() { beforeEach(function() { diff --git a/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js b/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js index 835cc88..43d0919 100644 --- a/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js +++ b/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js @@ -1,4 +1,4 @@ -describe('First Day : ', function() { +describe('firstDay', function() { beforeEach(function() { affix('#cal'); diff --git a/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js b/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js index 5054c93..55b83d9 100644 --- a/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js +++ b/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js @@ -1,11 +1,11 @@ -'use strict'; -describe('weekNumbers-defaultView:', function() { + +describe('weekNumbers-defaultView', function() { beforeEach(function() { affix('#cal'); }); - describe('when using basicWeek ', function() { + describe('when using basicWeek', function() { describe('with default weekNumbers ', function() { it('should not display weekNumbers', function() { $('#cal').fullCalendar({ @@ -25,7 +25,7 @@ describe('weekNumbers-defaultView:', function() { expect(weekNumbersCount).toEqual(0); }); }); - describe('with weekNumbers to true ', function() { + describe('with weekNumbers to true', function() { it('should display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'basicWeek', @@ -40,7 +40,7 @@ describe('weekNumbers-defaultView:', function() { }); describe('when using basicDay', function() { - describe('with default weekNumbers ', function() { + describe('with default weekNumbers', function() { it('should not display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'basicDay' @@ -59,7 +59,7 @@ describe('weekNumbers-defaultView:', function() { expect(weekNumbersCount).toEqual(0); }); }); - describe('with weekNumbers to true ', function() { + describe('with weekNumbers to true', function() { it('should display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'basicDay', @@ -74,7 +74,7 @@ describe('weekNumbers-defaultView:', function() { }); describe('when using agendaWeek', function() { - describe('with default weekNumbers ', function() { + describe('with default weekNumbers', function() { it('should not display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'agendaWeek' @@ -93,7 +93,7 @@ describe('weekNumbers-defaultView:', function() { expect(weekNumbersCount).toEqual(0); }); }); - describe('with weekNumbers to true ', function() { + describe('with weekNumbers to true', function() { it('should display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'agendaWeek', @@ -107,7 +107,7 @@ describe('weekNumbers-defaultView:', function() { }); describe('when using agendaDay', function() { - describe('with default weekNumbers ', function() { + describe('with default weekNumbers', function() { it('should not display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'agendaDay' @@ -126,7 +126,7 @@ describe('weekNumbers-defaultView:', function() { expect(weekNumbersCount).toEqual(0); }); }); - describe('with weekNumbers to true ', function() { + describe('with weekNumbers to true', function() { it('should display weekNumbers', function() { $('#cal').fullCalendar({ defaultView: 'agendaDay', From 0479d82d94e0f16a4703c25ba3652787a21e04ce Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sat, 25 Jan 2014 20:04:57 -0800 Subject: [PATCH 03/14] automated testing utilities (jasmine plugins, jquery simulate) come from bower now --- bower.json | 5 ++++- karma.conf.IntegrationTests.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index a6d5962..5d2f23d 100644 --- a/bower.json +++ b/bower.json @@ -3,6 +3,9 @@ "version": "1.6.4", "devDependencies": { "jquery": "~1.10.2", - "jquery-ui": "~1.10.3" + "jquery-ui": "~1.10.3", + "jquery-simulate": "*", + "jasmine-jquery": "~1.7.0", + "jasmine-fixture": "~1.0.8" } } diff --git a/karma.conf.IntegrationTests.js b/karma.conf.IntegrationTests.js index a238813..6865f78 100644 --- a/karma.conf.IntegrationTests.js +++ b/karma.conf.IntegrationTests.js @@ -11,10 +11,10 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ { pattern: './lib/jquery/jquery.js', watched: false }, - { pattern: './lib/jquery-simulate/*.js', watched: false }, - { pattern: './lib/jasmine-jquery/*.js', watched: false }, { pattern: './lib/jquery-ui/ui/jquery-ui.js', watched: false }, - { pattern: './lib/jasmine-fixture/*.js', watched: false }, + { pattern: 'lib/jquery-simulate/jquery.simulate.js', watched: false }, + { pattern: 'lib/jasmine-jquery/lib/jasmine-jquery.js', watched: false }, + { pattern: 'lib/jasmine-fixture/dist/jasmine-fixture.js', watched: false }, './build/out/fullcalendar.js', './build/out/fullcalendar.css', './specs/fullCalendar*.js' From cdd3f29e98d8aadb99167daf8504e03aebda366e Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sat, 25 Jan 2014 22:08:35 -0800 Subject: [PATCH 04/14] moved automated test files to new locations --- karma.conf.IntegrationTests.js => karma.conf.js | 11 ++++++----- .../automated/allDaySlot.js | 0 .../automated/allDayText.js | 0 .../automated/aspectRatio.js | 0 .../automated/complex-firstDay-isRTL.js | 0 .../automated/complex-headerDateClick.js | 0 .../automated/complex-weekNumbers-defaultView.js | 0 .../automated/contentHeight.js | 0 .../automated/firstDay.js | 0 {specs => tests/automated}/fullCalendar.js | 0 .../automated/handleWindowResize.js | 0 .../automated/header.js | 0 .../automated/height.js | 0 .../automated/hiddenDays.js | 0 .../automated/isRTL.js | 0 .../automated/minTime.js | 0 .../automated/slotMinutes.js | 0 .../automated/weekMode.js | 0 .../automated/weekNumberCalculation.js | 0 .../automated/weekNumbers.js | 0 .../automated/weekends.js | 0 21 files changed, 6 insertions(+), 5 deletions(-) rename karma.conf.IntegrationTests.js => karma.conf.js (86%) rename specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js => tests/automated/allDaySlot.js (100%) rename specs/fullCalendarSpecs-AgendaOptions-allDayText.js => tests/automated/allDayText.js (100%) rename specs/fullCalendarSpecs-options-aspectRatio.js => tests/automated/aspectRatio.js (100%) rename specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js => tests/automated/complex-firstDay-isRTL.js (100%) rename specs/fullCalendarSpecs-options-headerDateClick.js => tests/automated/complex-headerDateClick.js (100%) rename specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js => tests/automated/complex-weekNumbers-defaultView.js (100%) rename specs/fullCalendarSpecs-options-contentHeight.js => tests/automated/contentHeight.js (100%) rename specs/fullCalendarSpecs-options-firstDay.js => tests/automated/firstDay.js (100%) rename {specs => tests/automated}/fullCalendar.js (100%) rename specs/fullCalendarSpecs-options-handleWindowResize.js => tests/automated/handleWindowResize.js (100%) rename specs/fullCalendarSpecs-options-header.js => tests/automated/header.js (100%) rename specs/fullCalendarSpecs-options-height.js => tests/automated/height.js (100%) rename specs/fullCalendarSpecs-options-hiddenDays.js => tests/automated/hiddenDays.js (100%) rename specs/fullCalendarSpecs-options-isRTL.js => tests/automated/isRTL.js (100%) rename specs/fullCalendarSpecs-AgendaOptions-minTime.js => tests/automated/minTime.js (100%) rename specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js => tests/automated/slotMinutes.js (100%) rename specs/fullCalendarSpecs-options-weekMode.js => tests/automated/weekMode.js (100%) rename specs/fullCalendarSpecs-options-weekNumberCalculation.js => tests/automated/weekNumberCalculation.js (100%) rename specs/fullCalendarSpecs-options-weekNumbers.js => tests/automated/weekNumbers.js (100%) rename specs/fullCalendarSpecs-options-weekends.js => tests/automated/weekends.js (100%) diff --git a/karma.conf.IntegrationTests.js b/karma.conf.js similarity index 86% rename from karma.conf.IntegrationTests.js rename to karma.conf.js index 6865f78..a90bbf1 100644 --- a/karma.conf.IntegrationTests.js +++ b/karma.conf.js @@ -10,14 +10,15 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - { pattern: './lib/jquery/jquery.js', watched: false }, - { pattern: './lib/jquery-ui/ui/jquery-ui.js', watched: false }, + { pattern: 'lib/jquery/jquery.js', watched: false }, + { pattern: 'lib/jquery-ui/ui/jquery-ui.js', watched: false }, { pattern: 'lib/jquery-simulate/jquery.simulate.js', watched: false }, { pattern: 'lib/jasmine-jquery/lib/jasmine-jquery.js', watched: false }, { pattern: 'lib/jasmine-fixture/dist/jasmine-fixture.js', watched: false }, - './build/out/fullcalendar.js', - './build/out/fullcalendar.css', - './specs/fullCalendar*.js' + 'build/out/fullcalendar.js', + 'build/out/fullcalendar.css', + 'tests/base.css', + 'tests/automated/*.js' ], // list of files to exclude diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js b/tests/automated/allDaySlot.js similarity index 100% rename from specs/fullCalendarSpecs-AgendaOptions-allDaySlots.js rename to tests/automated/allDaySlot.js diff --git a/specs/fullCalendarSpecs-AgendaOptions-allDayText.js b/tests/automated/allDayText.js similarity index 100% rename from specs/fullCalendarSpecs-AgendaOptions-allDayText.js rename to tests/automated/allDayText.js diff --git a/specs/fullCalendarSpecs-options-aspectRatio.js b/tests/automated/aspectRatio.js similarity index 100% rename from specs/fullCalendarSpecs-options-aspectRatio.js rename to tests/automated/aspectRatio.js diff --git a/specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js b/tests/automated/complex-firstDay-isRTL.js similarity index 100% rename from specs/fullCalendarSpecs-optionsCombinations-firstDay-isRTL.js rename to tests/automated/complex-firstDay-isRTL.js diff --git a/specs/fullCalendarSpecs-options-headerDateClick.js b/tests/automated/complex-headerDateClick.js similarity index 100% rename from specs/fullCalendarSpecs-options-headerDateClick.js rename to tests/automated/complex-headerDateClick.js diff --git a/specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js b/tests/automated/complex-weekNumbers-defaultView.js similarity index 100% rename from specs/fullCalendarSpecs-optionsCombinations-weekNumbers-defaultView.js rename to tests/automated/complex-weekNumbers-defaultView.js diff --git a/specs/fullCalendarSpecs-options-contentHeight.js b/tests/automated/contentHeight.js similarity index 100% rename from specs/fullCalendarSpecs-options-contentHeight.js rename to tests/automated/contentHeight.js diff --git a/specs/fullCalendarSpecs-options-firstDay.js b/tests/automated/firstDay.js similarity index 100% rename from specs/fullCalendarSpecs-options-firstDay.js rename to tests/automated/firstDay.js diff --git a/specs/fullCalendar.js b/tests/automated/fullCalendar.js similarity index 100% rename from specs/fullCalendar.js rename to tests/automated/fullCalendar.js diff --git a/specs/fullCalendarSpecs-options-handleWindowResize.js b/tests/automated/handleWindowResize.js similarity index 100% rename from specs/fullCalendarSpecs-options-handleWindowResize.js rename to tests/automated/handleWindowResize.js diff --git a/specs/fullCalendarSpecs-options-header.js b/tests/automated/header.js similarity index 100% rename from specs/fullCalendarSpecs-options-header.js rename to tests/automated/header.js diff --git a/specs/fullCalendarSpecs-options-height.js b/tests/automated/height.js similarity index 100% rename from specs/fullCalendarSpecs-options-height.js rename to tests/automated/height.js diff --git a/specs/fullCalendarSpecs-options-hiddenDays.js b/tests/automated/hiddenDays.js similarity index 100% rename from specs/fullCalendarSpecs-options-hiddenDays.js rename to tests/automated/hiddenDays.js diff --git a/specs/fullCalendarSpecs-options-isRTL.js b/tests/automated/isRTL.js similarity index 100% rename from specs/fullCalendarSpecs-options-isRTL.js rename to tests/automated/isRTL.js diff --git a/specs/fullCalendarSpecs-AgendaOptions-minTime.js b/tests/automated/minTime.js similarity index 100% rename from specs/fullCalendarSpecs-AgendaOptions-minTime.js rename to tests/automated/minTime.js diff --git a/specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js b/tests/automated/slotMinutes.js similarity index 100% rename from specs/fullCalendarSpecs-AgendaOptions-slotMinutes.js rename to tests/automated/slotMinutes.js diff --git a/specs/fullCalendarSpecs-options-weekMode.js b/tests/automated/weekMode.js similarity index 100% rename from specs/fullCalendarSpecs-options-weekMode.js rename to tests/automated/weekMode.js diff --git a/specs/fullCalendarSpecs-options-weekNumberCalculation.js b/tests/automated/weekNumberCalculation.js similarity index 100% rename from specs/fullCalendarSpecs-options-weekNumberCalculation.js rename to tests/automated/weekNumberCalculation.js diff --git a/specs/fullCalendarSpecs-options-weekNumbers.js b/tests/automated/weekNumbers.js similarity index 100% rename from specs/fullCalendarSpecs-options-weekNumbers.js rename to tests/automated/weekNumbers.js diff --git a/specs/fullCalendarSpecs-options-weekends.js b/tests/automated/weekends.js similarity index 100% rename from specs/fullCalendarSpecs-options-weekends.js rename to tests/automated/weekends.js From 55eb4d83e8b1ea71a0a6b1cd5a32a6332ef6094f Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sun, 26 Jan 2014 13:58:37 -0800 Subject: [PATCH 05/14] add automated testing instructions to readme --- readme.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index ea0001f..9c8f611 100644 --- a/readme.md +++ b/readme.md @@ -45,10 +45,20 @@ If you want to clean up the generated files, run: grunt clean -Writing Tests -------------- +Automated Testing +----------------- -When fixing a bug or writing a feature, please make a corresponding HTML file in the `./tests/` directory to visually demonstrate your work. If the test requires user intervention to prove its point, please write instructions for the user to follow. Explore the existing tests for more info. +To run automated tests, you must first install [karma] globally: + + npm install -g karma + +Then, assuming all your source files have been built (via `grunt dev` or `watch`), you can run the tests from a browser: + + karma start --single-run + +This will output a URL that you can visit in a browser. Alternatively, you can run the tests headlessly: + + karma start --single-run --browsers PhantomJS [fc-homepage]: http://arshaw.com/fullcalendar/ @@ -56,4 +66,5 @@ When fixing a bug or writing a feature, please make a corresponding HTML file in [node]: http://nodejs.org/ [grunt-cli]: http://gruntjs.com/getting-started#installing-the-cli [bower]: http://bower.io/ -[jq-readme]: https://github.com/jquery/jquery/blob/master/README.md#what-you-need-to-build-your-own-jquery \ No newline at end of file +[jq-readme]: https://github.com/jquery/jquery/blob/master/README.md#what-you-need-to-build-your-own-jquery +[karma]: http://karma-runner.github.io/0.10/index.html \ No newline at end of file From 4ec2dfac819bdbaa0d30805522b857ea596cb683 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 27 Jan 2014 23:52:01 -0800 Subject: [PATCH 06/14] let karma know about the moment dependency --- karma.conf.js | 1 + 1 file changed, 1 insertion(+) diff --git a/karma.conf.js b/karma.conf.js index a90bbf1..49e04c8 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,6 +10,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ + { pattern: 'lib/moment/moment.js', watched: false }, { pattern: 'lib/jquery/jquery.js', watched: false }, { pattern: 'lib/jquery-ui/ui/jquery-ui.js', watched: false }, { pattern: 'lib/jquery-simulate/jquery.simulate.js', watched: false }, From bbc5fd9853ea5eaca526ab668e5cf6b39d45e2ae Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 27 Jan 2014 23:43:44 -0800 Subject: [PATCH 07/14] fixed regression where fullCalendar wouldn't intialize without options --- src/Calendar.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Calendar.js b/src/Calendar.js index 18b78e5..b7f77e2 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -9,6 +9,8 @@ function Calendar(element, instanceOptions) { // ----------------------------------------------------------------------------------- // Precedence (lowest to highest): defaults, rtlDefaults, langOptions, instanceOptions + instanceOptions = instanceOptions || {}; + var options = mergeOptions({}, defaults, instanceOptions); var langOptions; From 161a476980e09f454bef898332f3ee2f2072caba Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 27 Jan 2014 23:45:09 -0800 Subject: [PATCH 08/14] fixed regression where weekNumberCalculation as a function wouldn't work --- src/Calendar.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Calendar.js b/src/Calendar.js index b7f77e2..b9a7dac 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -146,15 +146,16 @@ function Calendar(element, instanceOptions) { // `weekNumberCalculation` setting. t.calculateWeekNumber = function(mom) { var calc = options.weekNumberCalculation; - if (calc == 'local') { + + if (typeof calc === 'function') { + return calc(mom); + } + else if (calc === 'local') { return mom.week(); } - else if (calc.toUpperCase() == 'ISO') { + else if (calc.toUpperCase() === 'ISO') { return mom.isoWeek(); } - else if (typeof calc === 'function') { - return calc(mom); - } }; From 8552600c24065d1ace9d61b341392369a317d85b Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 27 Jan 2014 23:48:14 -0800 Subject: [PATCH 09/14] always set minheight on rows, even when very large aspectRatio --- src/basic/BasicView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/BasicView.js b/src/basic/BasicView.js index 204db3f..8415036 100644 --- a/src/basic/BasicView.js +++ b/src/basic/BasicView.js @@ -290,7 +290,7 @@ function BasicView(element, calendar, viewName) { function setHeight(height) { viewHeight = height; - var bodyHeight = viewHeight - head.height(); + var bodyHeight = Math.max(viewHeight - head.height(), 0); var rowHeight; var rowHeightLast; var cell; From 316e94412d547f860a95945e01d4437dd27479eb Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 27 Jan 2014 23:49:41 -0800 Subject: [PATCH 10/14] upgrade to moment 2.5.1 and resolve cloning issue With moment 2.5.1, when moments are cloned, not all their properties are blindly copied over, like our ambig-time/ambig-zone properties. Force this to happen by monkey-patching. --- bower.json | 2 +- src/date_util.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 7c5b88e..bf378a5 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "fullcalendar", "version": "2.0.0-beta", "devDependencies": { - "moment": ">=2.5.0", + "moment": "~2.5.1", "jquery": "~1.10.2", "jquery-ui": "~1.10.3", "jquery-simulate": "*", diff --git a/src/date_util.js b/src/date_util.js index d33f9bd..e75a77d 100644 --- a/src/date_util.js +++ b/src/date_util.js @@ -2,6 +2,7 @@ var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; var ambigTimeRegex = /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))$/; var ambigZoneRegex = /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?)?$/; +var momentCloneMethod = moment.fn.clone; var momentFormatMethod = moment.fn.format; var momentToISOStringMethod = moment.fn.toISOString; @@ -47,6 +48,7 @@ fc.moment.parseZone = function() { // when parseZone==true, if can't figure it out, fall back to parseUTC function buildMoment(args, parseUTC, parseZone) { var isSingleArg = args.length == 1; + var isSingleMoment = isSingleArg && moment.isMoment(args[0]); var isSingleString = isSingleArg && typeof args[0] === 'string'; var isSingleArray = isSingleArg && $.isArray(args[0]); var isSingleNativeDate = isSingleArg && isNativeDate(args[0]); @@ -61,6 +63,11 @@ function buildMoment(args, parseUTC, parseZone) { mom = moment.apply(null, args); } + // if we are essentially cloning a moment, transfer over existing _ambig properties + if (isSingleMoment) { + transferAmbigs(args[0], mom); + } + if (isAmbigTime) { mom._ambigTime = true; mom._ambigZone = true; // if ambiguous time, also ambiguous timezone offset @@ -86,6 +93,23 @@ function buildMoment(args, parseUTC, parseZone) { return mom; } +// we need to patch moment's clone method because it will not copy our _ambig properties +moment.fn.clone = function() { + var res = momentCloneMethod.apply(this, arguments); + transferAmbigs(this, res); + return res; +}; + +// transfers our internal _ambig properties from one moment to another, but only if true +function transferAmbigs(srcMoment, destMoment) { + if (srcMoment._ambigTime) { + destMoment._ambigTime = true; + } + if (srcMoment._ambigZone) { + destMoment._ambigZone = true; + } +} + // MOMENT: time-of-day // ------------------------------------------------------------------------------------------------- From 14145079d3657ef04690f0f667012325560d13fc Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 28 Jan 2014 00:01:35 -0800 Subject: [PATCH 11/14] refactor the jQuery fullCalendar adapter. don't allow calendar to initialize twice --- src/main.js | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/main.js b/src/main.js index efacf26..447e36e 100644 --- a/src/main.js +++ b/src/main.js @@ -4,37 +4,35 @@ var fcViews = fc.views = {}; $.fn.fullCalendar = function(options) { + var args = Array.prototype.slice.call(arguments, 1); // for a possible method call + var res = this; // what this function will return (this jQuery object by default) - // method calling - if (typeof options == 'string') { - var args = Array.prototype.slice.call(arguments, 1); - var res; - this.each(function() { - var calendar = $.data(this, 'fullCalendar'); + this.each(function(i, _element) { // loop each DOM element involved + var element = $(_element); + var calendar = element.data('fullCalendar'); // get the existing calendar object (if any) + var singleRes; // the returned value of this single method call + + // a method call + if (typeof options === 'string') { if (calendar && $.isFunction(calendar[options])) { - var r = calendar[options].apply(calendar, args); - if (res === undefined) { - res = r; + singleRes = calendar[options].apply(calendar, args); + if (!i) { + res = singleRes; // record the first method call result } - if (options == 'destroy') { - $.removeData(this, 'fullCalendar'); + if (options === 'destroy') { // for the destroy method, must remove Calendar object data + element.removeData('fullCalendar'); } } - }); - if (res !== undefined) { - return res; } - return this; - } - - this.each(function(i, _element) { - var element = $(_element); - var calendar = new Calendar(element, options); - element.data('fullCalendar', calendar); - calendar.render(); + // a new calendar initialization + else if (!calendar) { // don't initialize twice + calendar = new Calendar(element, options); + element.data('fullCalendar', calendar); + calendar.render(); + } }); - return this; + return res; }; From d4be172f5627afe55316ee1808d0c9430035cc9b Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 28 Jan 2014 00:04:29 -0800 Subject: [PATCH 12/14] update tests for options related to newly introduced Moment/Duration --- tests/automated/complex-headerDateClick.js | 20 ++++----- tests/automated/minTime.js | 28 ++++++------ tests/automated/slotMinutes.js | 12 ++--- tests/automated/weekMode.js | 52 +++++++++++----------- tests/automated/weekNumberCalculation.js | 7 +-- 5 files changed, 60 insertions(+), 59 deletions(-) diff --git a/tests/automated/complex-headerDateClick.js b/tests/automated/complex-headerDateClick.js index b12b9b0..ae0a0f7 100644 --- a/tests/automated/complex-headerDateClick.js +++ b/tests/automated/complex-headerDateClick.js @@ -15,46 +15,46 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct describe('and click next', function() { it('should change view to next month', function() { - $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('#calendar').fullCalendar('gotoDate', '2010-02-01'); $('.fc-button-next').simulate('click'); var newDate = $('#calendar').fullCalendar('getDate'); - expect(newDate).toEqual(new Date(2010, 2, 1)); + expect(newDate.format()).toEqual('2010-03-01'); }); }); describe('and click prev', function() { it('should change view to prev month', function() { - $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('#calendar').fullCalendar('gotoDate', '2010-02-01'); $('.fc-button-prev').simulate('click'); var newDate = $('#calendar').fullCalendar('getDate'); - expect(newDate).toEqual(new Date(2009, 12, 1)); + expect(newDate.format()).toEqual('2010-01-01'); }); }); describe('and click prevYear', function() { it('should change view to prev month', function() { - $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('#calendar').fullCalendar('gotoDate', '2010-02-01'); $('.fc-button-prevYear').simulate('click'); var newDate = $('#calendar').fullCalendar('getDate'); - expect(newDate).toEqual(new Date(2009, 1, 1)); + expect(newDate.format()).toEqual('2009-02-01'); }); }); describe('and click nextYear', function() { it('should change view to prev month', function() { - $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('#calendar').fullCalendar('gotoDate', '2010-02-01'); $('.fc-button-nextYear').simulate('click'); var newDate = $('#calendar').fullCalendar('getDate'); - expect(newDate).toEqual(new Date(2011, 1, 1)); + expect(newDate.format()).toEqual('2011-02-01'); }); }); describe('and click today', function() { it('should change view to prev month', function() { - $('#calendar').fullCalendar('gotoDate', 2010, 1, 1); + $('#calendar').fullCalendar('gotoDate', '2010-02-01'); $('.fc-button-today').simulate('click'); var newDate = $('#calendar').fullCalendar('getDate'); - expect(newDate.toDateString()).toEqual(new Date().toDateString()); + expect(newDate.format()).toEqual(moment().format()); }); }); }); \ No newline at end of file diff --git a/tests/automated/minTime.js b/tests/automated/minTime.js index 21f9e1b..44195ac 100644 --- a/tests/automated/minTime.js +++ b/tests/automated/minTime.js @@ -50,15 +50,15 @@ describe('minTime', function() { beforeEach(function() { affix('#cal2'); }); - hourNumbers.forEach(function(minTimeIn) { - it('should start at ' + minTimeIn, function() { + hourNumbers.forEach(function(hourNumber) { + it('should start at ' + hourNumber, function() { var options = { defaultView: 'agendaWeek', - minTime: minTimeIn + minTime: { hours: hourNumber } }; $('#cal2').fullCalendar(options); var firstSlotText = $('.fc-slot0 th').text(); - var expected = numToStringConverter(minTimeIn); + var expected = numToStringConverter(hourNumber); expect(firstSlotText).toEqual(expected); }); }); @@ -68,15 +68,15 @@ describe('minTime', function() { beforeEach(function() { affix('#cal2'); }); - hourNumbers.forEach(function(minTimeIn) { - it('should start at ' + minTimeIn, function() { + hourNumbers.forEach(function(hourNumber) { + it('should start at ' + hourNumber, function() { var options = { defaultView: 'agendaWeek', - minTime: minTimeIn + minTime: { hours: hourNumber } }; $('#cal2').fullCalendar(options); var firstSlotText = $('.fc-slot0 th').text(); - var expected = numToStringConverter(minTimeIn); + var expected = numToStringConverter(hourNumber); expect(firstSlotText).toEqual(expected); }); }); @@ -91,11 +91,11 @@ describe('minTime', function() { beforeEach(function() { affix('#cal2'); }); - hourNumbers.forEach(function(minTimeIn) { - it('should start at ' + minTimeIn + 0.12, function() { + hourNumbers.forEach(function(hourNumber) { + it('should start at ' + hourNumber + ':20', function() { var options = { defaultView: 'agendaWeek', - minTime: minTimeIn + 0.12 + minTime: { hours: hourNumber, minutes: 20 } }; $('#cal2').fullCalendar(options); var firstSlotElement = $('.fc-slot0')[0]; @@ -112,11 +112,11 @@ describe('minTime', function() { beforeEach(function() { affix('#cal2'); }); - hourNumbers.forEach(function(minTimeIn) { - it('should start at ' + minTimeIn + 0.12, function() { + hourNumbers.forEach(function(hourNumber) { + it('should start at ' + hourNumber + ':20', function() { var options = { defaultView: 'agendaWeek', - minTime: minTimeIn + 0.12 + minTime: { hours: hourNumber, minutes: 20 } }; $('#cal2').fullCalendar(options); var firstSlotElement = $('.fc-slot0')[0]; diff --git a/tests/automated/slotMinutes.js b/tests/automated/slotMinutes.js index aad0c08..3ffb963 100644 --- a/tests/automated/slotMinutes.js +++ b/tests/automated/slotMinutes.js @@ -61,15 +61,15 @@ describe('slotMinutes', function() { beforeEach(function() { affix('#cal2'); }); - slotMinutesList.forEach(function(slotMinutesIn) { + slotMinutesList.forEach(function(slotMinutes) { it('should have slots 1440/x slots', function() { var options = { defaultView: 'agendaWeek', - slotMinutes: slotMinutesIn + slotDuration: { minutes: slotMinutes } }; $('#cal2').fullCalendar(options); var slotCount = $('.fc-agenda-slots tr').length; - var expected = Math.ceil(minutesInADay / slotMinutesIn); + var expected = Math.ceil(minutesInADay / slotMinutes); expect(slotCount).toEqual(expected); }); }); @@ -79,15 +79,15 @@ describe('slotMinutes', function() { beforeEach(function() { affix('#cal2'); }); - slotMinutesList.forEach(function(slotMinutesIn) { + slotMinutesList.forEach(function(slotMinutes) { it('should have slots 1440/x slots', function() { var options = { defaultView: 'agendaWeek', - slotMinutes: slotMinutesIn + slotDuration: { minutes: slotMinutes } }; $('#cal2').fullCalendar(options); var slotCount = $('.fc-agenda-slots tr').length; - var expected = Math.ceil(minutesInADay / slotMinutesIn); + var expected = Math.ceil(minutesInADay / slotMinutes); expect(slotCount).toEqual(expected); }); }); diff --git a/tests/automated/weekMode.js b/tests/automated/weekMode.js index 8e6f362..e1b83da 100644 --- a/tests/automated/weekMode.js +++ b/tests/automated/weekMode.js @@ -13,26 +13,26 @@ describe('weekMode', function() { $('#cal').fullCalendar(); }); it('should show 6 weeks for a 5 week month', function() { - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#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, 2); + $('#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, 5); + $('#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, 1); + $('#cal').fullCalendar('gotoDate', '2009-02-01'); var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#cal').fullCalendar('gotoDate', '2013-10-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 5); + $('#cal').fullCalendar('gotoDate', '2013-06-01'); var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fourWeekHeight).toEqual(fiveWeekHeight); expect(fiveWeekHeight).toEqual(sixWeekHeight); @@ -46,17 +46,17 @@ describe('weekMode', function() { }); }); it('should show 6 weeks for a 5 week month', function() { - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#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, 2); + $('#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, 5); + $('#cal').fullCalendar('gotoDate', '2013-06-01'); var weekCount = $('.fc-week').length; expect(weekCount).toEqual(6); }); @@ -69,45 +69,45 @@ describe('weekMode', function() { }); }); it('should show 5 weeks for a 5 week month', function() { - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#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, 1); + $('#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, 5); + $('#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, 9); + $('#cal').fullCalendar('gotoDate', '2013-10-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 5); + $('#cal').fullCalendar('gotoDate', '2013-06-01'); var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight); }); it('should reduce height when moving from 5 weeks to 6 weeks', function() { - $('#cal').fullCalendar('gotoDate', 2013, 5); + $('#cal').fullCalendar('gotoDate', '2013-06-01'); var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#cal').fullCalendar('gotoDate', '2013-10-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight); }); it('should increase height when moving from 5 weeks to 4 weeks', function() { - $('#cal').fullCalendar('gotoDate', 2013, 4); + $('#cal').fullCalendar('gotoDate', '2013-05-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2009, 1); + $('#cal').fullCalendar('gotoDate', '2009-02-01'); var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight); }); it('should reduce height when moving from 4 weeks to 5 weeks', function() { - $('#cal').fullCalendar('gotoDate', 2009, 1); + $('#cal').fullCalendar('gotoDate', '2009-02-01'); var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 4); + $('#cal').fullCalendar('gotoDate', '2013-05-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight); }); @@ -120,26 +120,26 @@ describe('weekMode', function() { }); }); it('should show 5 weeks for a 5 week month', function() { - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#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, 1); + $('#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, 5); + $('#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, 1); + $('#cal').fullCalendar('gotoDate', '2009-02-01'); var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 9); + $('#cal').fullCalendar('gotoDate', '2013-10-01'); var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); - $('#cal').fullCalendar('gotoDate', 2013, 5); + $('#cal').fullCalendar('gotoDate', '2013-06-01'); var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height')); expect(fourWeekHeight).toEqual(fiveWeekHeight); expect(fiveWeekHeight).toEqual(sixWeekHeight); diff --git a/tests/automated/weekNumberCalculation.js b/tests/automated/weekNumberCalculation.js index ff3c49b..5b91f0b 100644 --- a/tests/automated/weekNumberCalculation.js +++ b/tests/automated/weekNumberCalculation.js @@ -9,9 +9,10 @@ describe('weekNumberCalculation', function() { it('should return iso standard', function() { $('#cal').fullCalendar({ editable: true, - weekNumbers: true + weekNumbers: true, + weekNumberCalculation: 'ISO' }); - $('#cal').fullCalendar('gotoDate', 2013, 10, 17); + $('#cal').fullCalendar('gotoDate', '2013-11-17'); var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text()); expect(weekNum).toEqual(43); }); @@ -26,7 +27,7 @@ describe('weekNumberCalculation', function() { return 4; } }); - $('#cal').fullCalendar('gotoDate', 2013, 10, 17); + $('#cal').fullCalendar('gotoDate', '2013-11-17'); var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text()); expect(weekNum).toEqual(4); }); From 588fc25e397a84f02e6cd0bc4a81e98345a04a7d Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 28 Jan 2014 00:03:23 -0800 Subject: [PATCH 13/14] fixup some existing tests --- tests/automated/aspectRatio.js | 11 +++++------ tests/automated/firstDay.js | 20 +++++++++----------- tests/automated/handleWindowResize.js | 3 ++- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/automated/aspectRatio.js b/tests/automated/aspectRatio.js index 9a15fe0..5a40650 100644 --- a/tests/automated/aspectRatio.js +++ b/tests/automated/aspectRatio.js @@ -128,12 +128,11 @@ describe('aspectRatio', function() { var width = $('.fc-content').width(); expect(width).toEqual(1000); }); - it('should set the height to width ratio to 0.5', function() { - var width = $('.fc-content').width(); - var height = $('.fc-content').height(); - var pxHeightPerCharacter = 22; - var defaultWeeksInCal = 7; - expect(height).toEqual(pxHeightPerCharacter * defaultWeeksInCal) + it('should cause rows to be natural height', function() { + var actualHeight = $('.fc-content').height(); + $('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red'); + var naturalHeight = $('.fc-content').height(); + expect(actualHeight).toEqual(naturalHeight) }); }); }); diff --git a/tests/automated/firstDay.js b/tests/automated/firstDay.js index b617468..4f7e58d 100644 --- a/tests/automated/firstDay.js +++ b/tests/automated/firstDay.js @@ -149,19 +149,17 @@ describe('First Day', function() { }); describe('when new firstDay options are set', function() { - it('should change the first day of the week', function() { - var options = { + it('should change the first day of week to Monday', function() { + $('#cal').fullCalendar({ firstDay: 1 - }; - $('#cal').fullCalendar(options); - var firstDayBeforeChange = $('.fc-day-header')[0]; - var newOptions = { + }); + expect($('.fc-day-header')[0]).toHaveClass('fc-mon'); + }); + it('shoule change the first day of week to Thursday', function() { + $('#cal').fullCalendar({ firstDay: 4 - }; - $('#cal').fullCalendar(newOptions); - var firstDayAfterChange = $('.fc-day-header')[0]; - expect(firstDayBeforeChange).toHaveClass('fc-mon'); - expect(firstDayAfterChange).toHaveClass('fc-thu'); + }); + expect($('.fc-day-header')[0]).toHaveClass('fc-thu'); }); }); }); \ No newline at end of file diff --git a/tests/automated/handleWindowResize.js b/tests/automated/handleWindowResize.js index bc050c4..0731287 100644 --- a/tests/automated/handleWindowResize.js +++ b/tests/automated/handleWindowResize.js @@ -5,7 +5,8 @@ describe('handleWindowResize', function() { affix('#cal'); }); - describe('When default is used, should fire resize event', function() { + // not true + xdescribe('When default is used, should fire resize event', function() { it('should fire resize', function() { var resized = 0; $('#cal').fullCalendar({ From 2f6f8055b78ff97e1b58e31997be8ec8db0ca3a4 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 28 Jan 2014 00:04:52 -0800 Subject: [PATCH 14/14] add some more tests --- tests/automated/fullCalendar.js | 9 +++++++-- tests/automated/moment-ambig.js | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/automated/moment-ambig.js diff --git a/tests/automated/fullCalendar.js b/tests/automated/fullCalendar.js index 9a55625..e2c3eb2 100644 --- a/tests/automated/fullCalendar.js +++ b/tests/automated/fullCalendar.js @@ -1,11 +1,16 @@ -describe('fullCalendar(Integration)', function() { +describe('fullCalendar constructor', function() { beforeEach(function() { affix('#calendar'); }); - describe('When fullCalendar() is called on a div', function() { + it('should return a jQuery object for chaining', function() { + var res = $('#calendar').fullCalendar(); + expect(res instanceof jQuery).toBe(true); + }); + + describe('when called on a div', function() { beforeEach(function() { $('#calendar').fullCalendar(); diff --git a/tests/automated/moment-ambig.js b/tests/automated/moment-ambig.js new file mode 100644 index 0000000..5d3c4fa --- /dev/null +++ b/tests/automated/moment-ambig.js @@ -0,0 +1,36 @@ + +describe('ambiguously-timed moment', function() { + + it('formats without a time and timezone part', function() { + var date = moment.utc('2014-01-01T06:00:00+00:00').stripTime(); + var s = date.format(); + expect(s).toEqual('2014-01-01'); + }); + + it('is still ambuously-timed after being cloned', function() { + var date = moment('2014-01-01T06:00:00-07:00').stripTime(); + var clone = date.clone(); + expect(date.hasTime()).toEqual(false); + expect(clone.hasTime()).toEqual(false); + }); + +}); + +describe('ambiguously-zoned moment', function() { + + it('formats without a timezone part', function() { + var date = moment.utc('2014-01-01T06:00:00+00:00').stripZone(); + var s = date.format(); + expect(s).toEqual('2014-01-01T06:00:00'); + }); + + it('is still ambiguously-zoned after being cloned', function() { + var date = moment('2014-01-01T06:00:00-07:00').stripZone(); + var clone = date.clone(); + expect(date.hasZone()).toEqual(false); + expect(clone.hasZone()).toEqual(false); + }); + +}); + +// TODO: also for $.fullCalendar.moment() and calendar.moment() \ No newline at end of file