This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/
months_day_test.js
150 lines (121 loc) · 3.68 KB
/
months_day_test.js
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
define(function(require) {
'use strict';
var DayChild = require('views/day_child');
var DayTemplate = require('templates/day');
var MonthsDay = require('views/months_day');
var dateFormat = require('date_format');
suite('Views.MonthsDay', function() {
var subject,
app,
controller,
events,
template,
busytimes;
teardown(function() {
var el = document.getElementById('test');
el.parentNode.removeChild(el);
});
setup(function() {
var div = document.createElement('div');
div.id = 'test';
div.innerHTML = [
'<div id="months-day-view">',
'<div class="day-events"></div>',
'</div>'
].join(' ');
document.body.appendChild(div);
app = testSupport.calendar.app();
controller = app.timeController;
events = app.store('Event');
busytimes = app.store('Busytime');
subject = new MonthsDay({ app: app });
template = DayTemplate;
});
test('initializer', function() {
assert.instanceOf(subject, DayChild);
});
test('bug 803934', function() {
// verify flag is false
assert.isFalse(subject.renderAllHours);
});
test('#changeDate', function() {
var currentDate = {
textContent: '',
dataset: {}
};
sinon.stub(subject, '_findElement')
.withArgs('currentDate')
.returns(currentDate);
subject._toggleEmptyMessage = sinon.spy();
var now = new Date();
var format = 'months-day-view-header-format';
subject.changeDate(now);
assert.deepEqual(currentDate.textContent, dateFormat.localeFormat(
now,
navigator.mozL10n.get(format)
), 'should set the currentDate textContent');
assert.deepEqual(currentDate.dataset, {
date: now,
l10nDateFormat: format
}, 'should set l10n dataset');
assert.ok(
subject._toggleEmptyMessage.calledOnce,
'should call _toggleEmptyMessage'
);
});
suite('#handleEvent', function() {
/*
// This test is currently failing and has been temporarily disabled as per
// Bug 838993. It should be fixed and re-enabled as soon as possible as per
// Bug 840489.
// This test appears to make incorrect assumptions about localization details
// (it does not fail on systems configured for US English).
test('selectedDayChange', function() {
var date = new Date(2012, 1, 1);
var calledWith;
// start with different date...
subject.date = new Date(2012, 1, 27);
// initialize events
subject.render();
subject.changeDate = function() {
Calendar.Views.MonthsDay.prototype.changeDate.apply(
this, arguments
);
calledWith = arguments;
};
subject.controller.selectedDay = date;
assert.equal(
calledWith[0],
date,
'should change date in view when controller changes'
);
assert.deepEqual(
subject.date,
date
);
var html = subject.header.outerHTML;
assert.ok(html);
assert.include(html, date.toLocaleFormat('%A'));
});
*/
});
/*
// This test is currently failing and has been temporarily disabled as per
// Bug 838993. It should be fixed and re-enabled as soon as possible as per
// Bug 840489.
// This test appears to make incorrect assumptions about localization details
// (it does not fail on systems configured for US English).
test('#render', function() {
var date = new Date();
var span = Calendar.Calc.spanOfDay(date);
subject.render();
assert.deepEqual(subject.timespan, span);
assert.ok(subject.allDayElement, 'has all day');
assert.ok(subject.events, 'has events');
var html = subject.header.outerHTML;
assert.ok(html);
assert.include(html, date.toLocaleFormat('%A'));
});
*/
});
});