From fc5d68806440f3e96e09ec227b47e8fdf1fa2da8 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Thu, 22 May 2014 20:42:35 +0200 Subject: [PATCH 1/6] Testing default, non-default and user-specified short daynames --- demos/default.html | 1 + tests/automated/dayNamesShort.js | 61 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/automated/dayNamesShort.js diff --git a/demos/default.html b/demos/default.html index 9d6eb7c..79b38fc 100644 --- a/demos/default.html +++ b/demos/default.html @@ -15,6 +15,7 @@ $('#calendar').fullCalendar({ defaultDate: '2014-01-12', editable: true, + weekends: false, events: [ { title: 'All Day Event', diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js new file mode 100644 index 0000000..4c5451f --- /dev/null +++ b/tests/automated/dayNamesShort.js @@ -0,0 +1,61 @@ +describe('day names', function() { + var settings = {}; + + beforeEach(function() { + affix('#cal'); + settings = { + } + }); + + //describe('when view is basic'); + //describe('when view is agenda'); + describe('when view is month', function() { + describe('when lang is default', function() { + beforeEach(function() { + moment.lang(); + }); + + it('should be in the default language and order', function() { + $('#cal').fullCalendar(settings); + var weekdays = moment.weekdaysShort(); + + $('.fc-day-header').each(function(index, item) { + expect(item).toHaveText(weekdays[index]); + }); + }); + }); + + describe('when lang is not default', function() { + var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]; + + $.each(languages, function(index, language) { + it('should be in the selected language and corresponding order', function() { + settings.lang = language; + $('#cal').fullCalendar(settings); + + moment.lang(language); + var dow = moment.langData(language)._week.dow + var weekdays = moment.weekdaysShort(); + + $('.fc-day-header').each(function(index, item) { + expect(item).toContainText(weekdays[(index + dow) % 7]); + }); + }); + }); + }); + + describe('when specified', function() { + it('should contain the specified names in the given order', function() { + var days = [ + 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' + ] + settings.dayNamesShort = days; + $('#cal').fullCalendar(settings); + + $('.fc-day-header').each(function(index, item) { + expect(item).toContainText(days[index]); + }); + }); + }); + }); +}); From b1e01e5e9b2ec5705a76862aa85c9dde7f97e06b Mon Sep 17 00:00:00 2001 From: David Asabina Date: Thu, 22 May 2014 20:57:16 +0200 Subject: [PATCH 2/6] Described the test for the agenda and basic view --- tests/automated/dayNamesShort.js | 58 +++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js index 4c5451f..2cb3d5c 100644 --- a/tests/automated/dayNamesShort.js +++ b/tests/automated/dayNamesShort.js @@ -1,4 +1,4 @@ -describe('day names', function() { +describe('short day names', function() { var settings = {}; beforeEach(function() { @@ -7,15 +7,63 @@ describe('day names', function() { } }); - //describe('when view is basic'); - //describe('when view is agenda'); + describe('when view is agenda', function() { + describe('when lang is default', function() { + beforeEach(function() { + moment.lang('en'); + }); + + it('should be in English, starting on Sunday', function() { + $('#cal').fullCalendar(settings); + var weekdays = moment.weekdaysShort(); + + $('.fc-day-header').each(function(index, item) { + expect(item).toContainText(weekdays[index]); + }); + }); + }); + + describe('when lang is not default', function() { + var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]; + + $.each(languages, function(index, language) { + it('should be in the selected language and corresponding order', function() { + settings.lang = language; + $('#cal').fullCalendar(settings); + + moment.lang(language); + var dow = moment.langData(language)._week.dow + var weekdays = moment.weekdaysShort(); + + $('.fc-day-header').each(function(index, item) { + expect(item).toContainText(weekdays[(index + dow) % 7]); + }); + }); + }); + }); + + describe('when specified', function() { + it('should contain the specified names in the given order', function() { + var days = [ + 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' + ] + settings.dayNamesShort = days; + $('#cal').fullCalendar(settings); + + $('.fc-day-header').each(function(index, item) { + expect(item).toContainText(days[index]); + }); + }); + }); + }); + describe('when view is month', function() { describe('when lang is default', function() { beforeEach(function() { - moment.lang(); + moment.lang('en'); }); - it('should be in the default language and order', function() { + it('should be in English, starting on Sunday', function() { $('#cal').fullCalendar(settings); var weekdays = moment.weekdaysShort(); From f91ef2444c5fe0a99edf8b8e054c328a8cb46a97 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Fri, 23 May 2014 22:53:10 +0200 Subject: [PATCH 3/6] Using expect inside a loop is probably not the smartest idea --- tests/automated/dayNamesShort.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js index 2cb3d5c..d4e4099 100644 --- a/tests/automated/dayNamesShort.js +++ b/tests/automated/dayNamesShort.js @@ -7,18 +7,33 @@ describe('short day names', function() { } }); - describe('when view is agenda', function() { + describe('when view is agendaWeek', function() { describe('when lang is default', function() { beforeEach(function() { moment.lang('en'); + settings.defaultView = 'agendaWeek'; }); it('should be in English, starting on Sunday', function() { $('#cal').fullCalendar(settings); var weekdays = moment.weekdaysShort(); - $('.fc-day-header').each(function(index, item) { - expect(item).toContainText(weekdays[index]); + var dayClasses = [ + '.fc-sun', + '.fc-mon', + '.fc-tue', + '.fc-wed', + '.fc-thu', + '.fc-fri', + '.fc-sat' + ]; + + //expect($('.fc-agenda-days thead .fc-sun')[0]).toContainText(weekdays[0]); + $.each(dayClasses, function(index, cls) { + (function(){ + expect($('.fc-agenda-days thead ' + cls)[0]).toContainText(weekdays[index]); + })(); + //console.log('dealing with ' + cls); }); }); }); From 5333aa0d063ea4e7cd584b58a4c42a7c41c8c236 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Sat, 24 May 2014 01:32:30 +0200 Subject: [PATCH 4/6] Reusing specs + finding els using fc-view as reference --- tests/automated/dayNamesShort.js | 140 ++++++++++--------------------- 1 file changed, 43 insertions(+), 97 deletions(-) diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js index d4e4099..d1d8678 100644 --- a/tests/automated/dayNamesShort.js +++ b/tests/automated/dayNamesShort.js @@ -1,5 +1,15 @@ describe('short day names', function() { var settings = {}; + var dayClasses = [ + '.fc-sun', + '.fc-mon', + '.fc-tue', + '.fc-wed', + '.fc-thu', + '.fc-fri', + '.fc-sat' + ]; + var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]; beforeEach(function() { affix('#cal'); @@ -7,116 +17,52 @@ describe('short day names', function() { } }); - describe('when view is agendaWeek', function() { - describe('when lang is default', function() { + ['month', 'agendaWeek', 'basicWeek'].forEach(function(viewClass, index, viewClasses) { + describe('when view is ' + viewClass, function() { beforeEach(function() { - moment.lang('en'); - settings.defaultView = 'agendaWeek'; + settings.defaultView = viewClass; }); - - it('should be in English, starting on Sunday', function() { - $('#cal').fullCalendar(settings); - var weekdays = moment.weekdaysShort(); - - var dayClasses = [ - '.fc-sun', - '.fc-mon', - '.fc-tue', - '.fc-wed', - '.fc-thu', - '.fc-fri', - '.fc-sat' - ]; - - //expect($('.fc-agenda-days thead .fc-sun')[0]).toContainText(weekdays[0]); - $.each(dayClasses, function(index, cls) { - (function(){ - expect($('.fc-agenda-days thead ' + cls)[0]).toContainText(weekdays[index]); - })(); - //console.log('dealing with ' + cls); - }); - }); - }); - describe('when lang is not default', function() { - var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]; - - $.each(languages, function(index, language) { - it('should be in the selected language and corresponding order', function() { - settings.lang = language; + describe('when lang is default', function() { + it('should be in English', function() { + moment.lang('en'); $('#cal').fullCalendar(settings); - - moment.lang(language); - var dow = moment.langData(language)._week.dow var weekdays = moment.weekdaysShort(); - $('.fc-day-header').each(function(index, item) { - expect(item).toContainText(weekdays[(index + dow) % 7]); + dayClasses.forEach(function(cls, index, classes) { + expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]); }); }); }); - }); - - describe('when specified', function() { - it('should contain the specified names in the given order', function() { - var days = [ - 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' - ] - settings.dayNamesShort = days; - $('#cal').fullCalendar(settings); - - $('.fc-day-header').each(function(index, item) { - expect(item).toContainText(days[index]); - }); - }); - }); - }); - - describe('when view is month', function() { - describe('when lang is default', function() { - beforeEach(function() { - moment.lang('en'); - }); - - it('should be in English, starting on Sunday', function() { - $('#cal').fullCalendar(settings); - var weekdays = moment.weekdaysShort(); - - $('.fc-day-header').each(function(index, item) { - expect(item).toHaveText(weekdays[index]); - }); - }); - }); - - describe('when lang is not default', function() { - var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]; - - $.each(languages, function(index, language) { - it('should be in the selected language and corresponding order', function() { - settings.lang = language; - $('#cal').fullCalendar(settings); - - moment.lang(language); - var dow = moment.langData(language)._week.dow - var weekdays = moment.weekdaysShort(); - - $('.fc-day-header').each(function(index, item) { - expect(item).toContainText(weekdays[(index + dow) % 7]); + + describe('when lang is not default', function() { + languages.forEach(function(language, index, languages) { + it('should be in the selected language', function() { + settings.lang = language; + $('#cal').fullCalendar(settings); + + moment.lang(language); + var dow = moment.langData(language)._week.dow + var weekdays = moment.weekdaysShort(); + + dayClasses.forEach(function(cls, index, classes) { + expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]); + }); }); }); }); - }); + + describe('when specified', function() { + it('should contain the specified names in the given order', function() { + var days = [ + 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' + ] + settings.dayNamesShort = days; + $('#cal').fullCalendar(settings); - describe('when specified', function() { - it('should contain the specified names in the given order', function() { - var days = [ - 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' - ] - settings.dayNamesShort = days; - $('#cal').fullCalendar(settings); - - $('.fc-day-header').each(function(index, item) { - expect(item).toContainText(days[index]); + dayClasses.forEach(function(cls, index, classes) { + expect($('.fc-view thead ' + cls)[0]).toContainText(days[index]); + }); }); }); }); From 054a44ab1699b2c2b69d1b114ffa91e3afd49bcf Mon Sep 17 00:00:00 2001 From: David Asabina Date: Sat, 24 May 2014 03:05:51 +0200 Subject: [PATCH 5/6] Moving testableClasses to seperate variable --- tests/automated/dayNamesShort.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js index d1d8678..2cdcc6c 100644 --- a/tests/automated/dayNamesShort.js +++ b/tests/automated/dayNamesShort.js @@ -1,5 +1,10 @@ describe('short day names', function() { var settings = {}; + var testableClasses = [ + 'month', + 'agendaWeek', + 'basicWeek', + ] var dayClasses = [ '.fc-sun', '.fc-mon', @@ -17,7 +22,7 @@ describe('short day names', function() { } }); - ['month', 'agendaWeek', 'basicWeek'].forEach(function(viewClass, index, viewClasses) { + testableClasses.forEach(function(viewClass, index, viewClasses) { describe('when view is ' + viewClass, function() { beforeEach(function() { settings.defaultView = viewClass; From ccde440850d783ae795950f4c98c88cbddbeac8b Mon Sep 17 00:00:00 2001 From: David Asabina Date: Sat, 24 May 2014 03:13:46 +0200 Subject: [PATCH 6/6] Fixing style issues --- demos/default.html | 1 - tests/automated/dayNamesShort.js | 25 ++++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/demos/default.html b/demos/default.html index 79b38fc..9d6eb7c 100644 --- a/demos/default.html +++ b/demos/default.html @@ -15,7 +15,6 @@ $('#calendar').fullCalendar({ defaultDate: '2014-01-12', editable: true, - weekends: false, events: [ { title: 'All Day Event', diff --git a/tests/automated/dayNamesShort.js b/tests/automated/dayNamesShort.js index 2cdcc6c..c2dc044 100644 --- a/tests/automated/dayNamesShort.js +++ b/tests/automated/dayNamesShort.js @@ -4,7 +4,7 @@ describe('short day names', function() { 'month', 'agendaWeek', 'basicWeek', - ] + ]; var dayClasses = [ '.fc-sun', '.fc-mon', @@ -18,8 +18,7 @@ describe('short day names', function() { beforeEach(function() { affix('#cal'); - settings = { - } + settings = { }; }); testableClasses.forEach(function(viewClass, index, viewClasses) { @@ -27,44 +26,44 @@ describe('short day names', function() { beforeEach(function() { settings.defaultView = viewClass; }); - + describe('when lang is default', function() { it('should be in English', function() { moment.lang('en'); $('#cal').fullCalendar(settings); var weekdays = moment.weekdaysShort(); - + dayClasses.forEach(function(cls, index, classes) { expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]); }); }); }); - + describe('when lang is not default', function() { languages.forEach(function(language, index, languages) { it('should be in the selected language', function() { settings.lang = language; $('#cal').fullCalendar(settings); - + moment.lang(language); - var dow = moment.langData(language)._week.dow + var dow = moment.langData(language)._week.dow; var weekdays = moment.weekdaysShort(); - + dayClasses.forEach(function(cls, index, classes) { expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]); }); }); }); }); - + describe('when specified', function() { it('should contain the specified names in the given order', function() { var days = [ - 'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj' - ] + 'Hov.', 'maS.', 'veS.', 'mech.', 'parmaq.', 'HoS.' + ]; settings.dayNamesShort = days; $('#cal').fullCalendar(settings); - + dayClasses.forEach(function(cls, index, classes) { expect($('.fc-view thead ' + cls)[0]).toContainText(days[index]); });