diff --git a/tests/automated/columnFormat.js b/tests/automated/columnFormat.js index af4c017..f1f79a9 100644 --- a/tests/automated/columnFormat.js +++ b/tests/automated/columnFormat.js @@ -61,8 +61,7 @@ describe('columnFormat', function() { }); }); - - describe('when lang is Fr', function() { + describe('when lang is French', function() { var viewWithFormat = [ { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' }, { view: 'basicWeek', expected: 'dim. 11/05', selector: 'th.fc-day-header.fc-sun' }, @@ -87,4 +86,30 @@ describe('columnFormat', function() { }; }); }); + + describe('when lang is Korean', function() { + + var viewWithFormat = [ { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' }, + { view: 'basicWeek', expected: '일 05.11', selector: 'th.fc-day-header.fc-sun' }, + { view: 'agendaWeek', expected: '일 05.11', selector: 'th.fc-widget-header.fc-sun' }, + { view: 'basicDay', expected: '일요일', selector: 'th.fc-day-header.fc-sun' }, + { view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ]; + + beforeEach(function() { + $('#cal').fullCalendar({ + defaultDate: '2014-05-11', + lang: 'ko' + }); + }); + + it('should have the translated dates and columnFormat should be computed differently', function() { + var cal = $('#cal'); + + for (var i = 0; i < viewWithFormat.length; i++) { + var crtView = viewWithFormat[i]; + cal.fullCalendar('changeView', crtView.view); + expect(cal.find(crtView.selector).text()).toBe(crtView.expected); + }; + }); + }); }); diff --git a/tests/automated/firstDay.js b/tests/automated/firstDay.js index a786e03..0773fe7 100644 --- a/tests/automated/firstDay.js +++ b/tests/automated/firstDay.js @@ -182,4 +182,20 @@ describe('First Day', function() { expect(daysOfWeek[6]).toHaveClass('fc-tue'); }); }); + + it('should have a different default value based on the language', function() { + $('#cal').fullCalendar({ + lang: 'en-gb' + }); + // firstDay will be 1 (Monday) in Great Britain + 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'); + }); + }); \ No newline at end of file diff --git a/tests/automated/isRTL.js b/tests/automated/isRTL.js new file mode 100644 index 0000000..435a236 --- /dev/null +++ b/tests/automated/isRTL.js @@ -0,0 +1,15 @@ +describe('isRTL', function() { + + it('has it\'s default value computed differently based off of the language', function() { + affix('#cal'); + $('#cal').fullCalendar({ + lang: 'ar' // Arabic is RTL + }); + var isRTL = $('#cal').fullCalendar('option', 'isRTL'); + expect(isRTL).toEqual(true); + }); + + // NOTE: don't put tests related to other options in here! + // Put them in the test file for the individual option! + +}); \ No newline at end of file diff --git a/tests/automated/lang.js b/tests/automated/lang.js index b1d3d82..2ed6928 100644 --- a/tests/automated/lang.js +++ b/tests/automated/lang.js @@ -1,29 +1,53 @@ describe('lang', function() { - /* + afterEach(function() { + moment.lang('en'); + }); - is not affected by global moment lang + it('is not affected by global moment lang when unset', function() { + moment.lang('fr'); + affix('#cal'); + $('#cal').fullCalendar(); + var calendar = $('#cal').fullCalendar('getCalendar'); + var mom = calendar.moment('2014-05-01'); + var s = mom.format('dddd MMMM Do YYYY'); + expect(s).toEqual('Thursday May 1st 2014'); + }); - doesn't affect the global moment lang when customized + it('is not affected by global moment lang when unset', function() { + moment.lang('fr'); + affix('#cal'); + $('#cal').fullCalendar({ + lang: 'es' + }); + var calendar = $('#cal').fullCalendar('getCalendar'); + var mom = calendar.moment('2014-05-01'); + var s = mom.format('dddd MMMM Do YYYY'); + expect(s).toEqual('jueves mayo 1º 2014'); + }); - defaults to english when configured to language that isn't loaded + it('doesn\'t side-effect the global moment lang when customized', function() { + moment.lang('fr'); + affix('#cal'); + $('#cal').fullCalendar({ + lang: 'es' + }); + var mom = moment.utc('2014-05-01'); + var s = mom.format('dddd MMMM Do YYYY'); + expect(s).toEqual('jeudi mai 1er 2014'); + expect(moment.lang()).toEqual('fr'); + }); - - ### below should be tested for in specific setting files - - is affected by the language's isRTL - uses the isRTL setting instead of the language's isRTL - - is affected by the language's firstDay - uses the firstDay setting instead of the language's firstDay - - computes the default columnFormat based on the language - uses the columnFormat setting instead of the language's columnFormat default - - computes the default timeFormat based on the language - uses the timeFormat setting instead of the language's timeFormat default - - */ + it('defaults to English when configured to language that isn\'t loaded', function() { + affix('#cal'); + $('#cal').fullCalendar({ + lang: 'zz' + }); + var calendar = $('#cal').fullCalendar('getCalendar'); + var mom = calendar.moment('2014-05-01'); + var s = mom.format('dddd MMMM Do YYYY'); + expect(s).toEqual('Thursday May 1st 2014'); + }); }); \ No newline at end of file