From 4980e14611a03211fa0cf8ba881adb5deeee8b44 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Wed, 28 May 2014 09:48:01 +0200 Subject: [PATCH 1/5] Basic setup for monthNames tests --- tests/automated/monthNames.js | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/automated/monthNames.js diff --git a/tests/automated/monthNames.js b/tests/automated/monthNames.js new file mode 100644 index 0000000..629c91b --- /dev/null +++ b/tests/automated/monthNames.js @@ -0,0 +1,64 @@ +describe('month name', function() { + var settings = {}; + var referenceDate = '2014-01-01 06:00'; // The day the world is hung-over + var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ]; + + beforeEach(function() { + affix('#cal'); + settings = { + now: moment(referenceDate).toISOString() + }; + }); + + afterEach(function() { + moment.lang('en'); // reset moment's global language + }); + + describe('when view is month', function() { + beforeEach(function() { + settings.defaultView = 'month'; + }); + + describe('when lang is default', function() { + beforeEach(function() { + settings.lang = 'en'; + moment.lang('en') + }); + + moment.months().forEach(function(month, index, months) { + it('should be ' + months[index], function() { + settings.now = moment(referenceDate).add('months', index); + $('#cal').fullCalendar(settings); + if(index == 0) console.log(moment.months()); + + // FIX: Selector often appears to point to a undefined object, wait for a callback to ensure all items are available in the DOM + expect($('.fc-header-title')[0]).toContainText(moment.months[index]); + }); + }); + }); + + languages.forEach(function(language, index, languages) { + describe('when lang is ' + language, function() { + beforeEach(function() { + settings.lang = language; + moment.lang(language) + }); + + moment.months().forEach(function(month, index, months) { + it('should be the translated name for ' + months[index], function() { + settings.now = moment(referenceDate).add('months', index); + $('#cal').fullCalendar(settings); + if(index == 0) console.log(moment.months()); + if(index == 0) console.log(settings.now.toISOString()); + if(index == 0) console.log($('.fc-header-title')[0].innerHTML); + + //expect($('.fc-header-title')[0]).toContainText(moment.months[index]); + }); + }); + }); + }); + + describe('when names are specified', function() {}); + + }); +}); From 17cef53fb4d1b9115441b90509a9804c68fbcb91 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Wed, 28 May 2014 11:46:16 +0200 Subject: [PATCH 2/5] testing monthnames in month view --- tests/automated/monthNames.js | 53 +++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/tests/automated/monthNames.js b/tests/automated/monthNames.js index 629c91b..96b0859 100644 --- a/tests/automated/monthNames.js +++ b/tests/automated/monthNames.js @@ -1,3 +1,4 @@ +// FIX: some tests are skipped from time to time, as if this file isn't even loaded by the test runner describe('month name', function() { var settings = {}; var referenceDate = '2014-01-01 06:00'; // The day the world is hung-over @@ -26,13 +27,14 @@ describe('month name', function() { }); moment.months().forEach(function(month, index, months) { - it('should be ' + months[index], function() { + it('should be ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); + settings.eventAfterAllRender = function() { + expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); + done(); + }; + $('#cal').fullCalendar(settings); - if(index == 0) console.log(moment.months()); - - // FIX: Selector often appears to point to a undefined object, wait for a callback to ensure all items are available in the DOM - expect($('.fc-header-title')[0]).toContainText(moment.months[index]); }); }); }); @@ -45,20 +47,47 @@ describe('month name', function() { }); moment.months().forEach(function(month, index, months) { - it('should be the translated name for ' + months[index], function() { + it('should be the translated name for ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); - $('#cal').fullCalendar(settings); - if(index == 0) console.log(moment.months()); - if(index == 0) console.log(settings.now.toISOString()); - if(index == 0) console.log($('.fc-header-title')[0].innerHTML); + settings.eventAfterAllRender = function() { + expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); + done(); + }; - //expect($('.fc-header-title')[0]).toContainText(moment.months[index]); + $('#cal').fullCalendar(settings); }); }); }); }); - describe('when names are specified', function() {}); + describe('when names are specified', function() { + var months = [ + 'I', + 'II', + 'III', + 'IV', + 'V', + 'VI', + 'VII', + 'IIX', + 'IX', + 'X', + 'XI', + 'XII' + ]; + months.forEach(function(month, index, months) { + it('should be the translated name for ' + months[index], function(done) { + settings.now = moment(referenceDate).add('months', index); + settings.monthNames = months; + settings.eventAfterAllRender = function() { + expect($('.fc-header-title')[0]).toContainText(month); + done(); + }; + + $('#cal').fullCalendar(settings); + }); + }); + }); }); }); From 3337519414ebcdbe2da858995b3a560040103cd7 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Wed, 28 May 2014 12:09:22 +0200 Subject: [PATCH 3/5] modified month view spec to test monthname in agendaDay and basicDay views --- tests/automated/monthNames.js | 123 ++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 58 deletions(-) diff --git a/tests/automated/monthNames.js b/tests/automated/monthNames.js index 96b0859..f32de5c 100644 --- a/tests/automated/monthNames.js +++ b/tests/automated/monthNames.js @@ -15,79 +15,86 @@ describe('month name', function() { moment.lang('en'); // reset moment's global language }); - describe('when view is month', function() { - beforeEach(function() { - settings.defaultView = 'month'; - }); - - describe('when lang is default', function() { + ['month', 'agendaDay', 'basicDay'].forEach(function(viewClass, index, viewClasses) { + describe('when view is ' + viewClass, function() { beforeEach(function() { - settings.lang = 'en'; - moment.lang('en') + settings.defaultView = viewClass; }); - - moment.months().forEach(function(month, index, months) { - it('should be ' + months[index], function(done) { - settings.now = moment(referenceDate).add('months', index); - settings.eventAfterAllRender = function() { - expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); - done(); - }; - - $('#cal').fullCalendar(settings); - }); - }); - }); - - languages.forEach(function(language, index, languages) { - describe('when lang is ' + language, function() { + + describe('when lang is default', function() { beforeEach(function() { - settings.lang = language; - moment.lang(language) + settings.lang = 'en'; + moment.lang('en') }); - + moment.months().forEach(function(month, index, months) { - it('should be the translated name for ' + months[index], function(done) { + it('should be ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); settings.eventAfterAllRender = function() { expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); done(); }; + + $('#cal').fullCalendar(settings); + }); + }); + }); + + languages.forEach(function(language, index, languages) { + describe('when lang is ' + language, function() { + beforeEach(function() { + settings.lang = language; + moment.lang(language) + }); + + moment.months().forEach(function(month, index, months) { + it('should be the translated name for ' + months[index], function(done) { + settings.now = moment(referenceDate).add('months', index); + settings.eventAfterAllRender = function() { + if(viewClass == 'month') { + expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); + } else { + expect($('.fc-header-title')[0]).toHaveText(settings.now.format('LL')); + } + done(); + }; + + $('#cal').fullCalendar(settings); + }); + }); + }); + }); + + describe('when names are specified', function() { + var months = [ + 'I', + 'II', + 'III', + 'IV', + 'V', + 'VI', + 'VII', + 'IIX', + 'IX', + 'X', + 'XI', + 'XII' + ]; + + months.forEach(function(month, index, months) { + it('should be the translated name for ' + months[index], function(done) { + settings.now = moment(referenceDate).add('months', index); + settings.monthNames = months; + settings.eventAfterAllRender = function() { + expect($('.fc-header-title')[0]).toContainText(month); + done(); + }; $('#cal').fullCalendar(settings); }); }); }); }); - - describe('when names are specified', function() { - var months = [ - 'I', - 'II', - 'III', - 'IV', - 'V', - 'VI', - 'VII', - 'IIX', - 'IX', - 'X', - 'XI', - 'XII' - ]; - - months.forEach(function(month, index, months) { - it('should be the translated name for ' + months[index], function(done) { - settings.now = moment(referenceDate).add('months', index); - settings.monthNames = months; - settings.eventAfterAllRender = function() { - expect($('.fc-header-title')[0]).toContainText(month); - done(); - }; - - $('#cal').fullCalendar(settings); - }); - }); - }); }); + }); From 19cc9f799fa43c47edd450abea7c1860440d8b05 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Wed, 28 May 2014 15:33:26 +0200 Subject: [PATCH 4/5] Cleaning up the style of my test --- tests/automated/monthNames.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/automated/monthNames.js b/tests/automated/monthNames.js index f32de5c..53910a5 100644 --- a/tests/automated/monthNames.js +++ b/tests/automated/monthNames.js @@ -15,18 +15,18 @@ describe('month name', function() { moment.lang('en'); // reset moment's global language }); - ['month', 'agendaDay', 'basicDay'].forEach(function(viewClass, index, viewClasses) { + [ 'month', 'agendaDay', 'basicDay' ].forEach(function(viewClass, index, viewClasses) { describe('when view is ' + viewClass, function() { beforeEach(function() { settings.defaultView = viewClass; }); - + describe('when lang is default', function() { beforeEach(function() { settings.lang = 'en'; - moment.lang('en') + moment.lang('en'); }); - + moment.months().forEach(function(month, index, months) { it('should be ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); @@ -34,37 +34,38 @@ describe('month name', function() { expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); done(); }; - + $('#cal').fullCalendar(settings); }); }); }); - + languages.forEach(function(language, index, languages) { describe('when lang is ' + language, function() { beforeEach(function() { settings.lang = language; - moment.lang(language) + moment.lang(language); }); - + moment.months().forEach(function(month, index, months) { it('should be the translated name for ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); settings.eventAfterAllRender = function() { - if(viewClass == 'month') { + if (viewClass == 'month') { // with month view check for occurence of the monthname in the title expect($('.fc-header-title')[0]).toContainText(moment.months()[index]); - } else { + } + else { // with day views ensure that title contains the properly formatted phrase expect($('.fc-header-title')[0]).toHaveText(settings.now.format('LL')); } done(); }; - + $('#cal').fullCalendar(settings); }); }); }); }); - + describe('when names are specified', function() { var months = [ 'I', @@ -80,7 +81,7 @@ describe('month name', function() { 'XI', 'XII' ]; - + months.forEach(function(month, index, months) { it('should be the translated name for ' + months[index], function(done) { settings.now = moment(referenceDate).add('months', index); @@ -89,7 +90,7 @@ describe('month name', function() { expect($('.fc-header-title')[0]).toContainText(month); done(); }; - + $('#cal').fullCalendar(settings); }); }); From 91451a4042f53579eba74b06db037b57ad17ceb0 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Wed, 28 May 2014 15:46:48 +0200 Subject: [PATCH 5/5] Removed a FIX note for occassionaly skipped tests --- tests/automated/monthNames.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/automated/monthNames.js b/tests/automated/monthNames.js index 53910a5..1f23669 100644 --- a/tests/automated/monthNames.js +++ b/tests/automated/monthNames.js @@ -1,4 +1,3 @@ -// FIX: some tests are skipped from time to time, as if this file isn't even loaded by the test runner describe('month name', function() { var settings = {}; var referenceDate = '2014-01-01 06:00'; // The day the world is hung-over