mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-09-12 12:21:04 +08:00
tests related to lang
This commit is contained in:
@@ -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);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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
@@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user