monthNames.js
3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
describe('month name', function() {
var settings = {};
var referenceDate = '2014-01-01'; // The day the world is hung-over
var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ];
beforeEach(function() {
affix('#cal');
settings = {
defaultDate: referenceDate
};
});
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 ' + month, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(month);
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) { // `month` will always be English
it('should be the translated name for ' + month, function(done) {
var langMonths = moment.months();
var langMonth = langMonths[index];
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.eventAfterAllRender = function() {
if (viewClass == 'month') { // with month view check for occurence of the monthname in the title
expect($('.fc-toolbar h2')).toContainText(langMonth);
}
else { // with day views ensure that title contains the properly formatted phrase
expect($('.fc-toolbar h2')).toHaveText(settings.defaultDate.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) { // `month` is our custom month name
it('should be the translated name for ' + month, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.monthNames = months;
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(month);
done();
};
$('#cal').fullCalendar(settings);
});
});
});
});
});
});