From 5333aa0d063ea4e7cd584b58a4c42a7c41c8c236 Mon Sep 17 00:00:00 2001 From: David Asabina Date: Sat, 24 May 2014 01:32:30 +0200 Subject: [PATCH] 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]); + }); }); }); });