tests related to lang

This commit is contained in:
Adam Shaw
2014-05-24 22:09:48 -07:00
parent 3ed9e7883d
commit a295c2b9d4
4 changed files with 102 additions and 22 deletions
+27 -2
View File
@@ -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);
};
});
});
});
+16
View File
@@ -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');
});
});
+15
View File
@@ -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!
});
+44 -20
View File
@@ -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');
});
});