mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-08-12 12:00:40 +08:00
Merge branch 'test/monthNames' of https://github.com/vidbina/fullcalendar into vidbina-test/monthNames
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
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
|
||||
});
|
||||
|
||||
[ '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.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() {
|
||||
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') { // with month view check for occurence of the monthname in the title
|
||||
expect($('.fc-header-title')[0]).toContainText(moment.months()[index]);
|
||||
}
|
||||
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',
|
||||
'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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user