Skip to content

Commit 176762e

Browse files
[DatePicker] Fix tests for the 31 of October
This is a temporary fix. There is an edge case with the test. Calling addMonths with 31 of October return 1 of December, while we expect November.
1 parent 6141e2b commit 176762e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/date-picker/calendar-spec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe(`Calendar`, () => {
2020

2121
describe(`Next Month Button`, () => {
2222
it(`should initially be disabled if the current month is the same as the month in the maxDate prop`, () => {
23-
let initialDate = new Date();
23+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
2424
let maxDate = new Date(initialDate.toDateString());
2525

2626
let render = TestUtils.renderIntoDocument(
@@ -38,9 +38,9 @@ describe(`Calendar`, () => {
3838
});
3939

4040
it(`should initially be disabled if the current month is after the month in the maxDate prop`, () => {
41-
let initialDate = new Date();
41+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
4242
let maxDate = new Date(initialDate.toDateString());
43-
maxDate.setMonth(maxDate.getMonth() - 1);
43+
maxDate = DateTime.addMonths(maxDate, -1);
4444

4545
let render = TestUtils.renderIntoDocument(
4646
<ThemedCalendar
@@ -56,9 +56,9 @@ describe(`Calendar`, () => {
5656
});
5757

5858
it(`should initially enable the next month button if the current month is before the maxDate prop`, () => {
59-
let initialDate = new Date();
59+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
6060
let maxDate = new Date(initialDate.toDateString());
61-
maxDate.setMonth(maxDate.getMonth() + 1);
61+
maxDate = DateTime.addMonths(maxDate, 1);
6262

6363
let render = TestUtils.renderIntoDocument(
6464
<ThemedCalendar
@@ -75,7 +75,7 @@ describe(`Calendar`, () => {
7575
});
7676

7777
it(`should reenable the next month button when the current month is before the maxDate prop`, () => {
78-
let initialDate = new Date();
78+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
7979
let maxDate = new Date(initialDate.toDateString());
8080

8181
let render = TestUtils.renderIntoDocument(
@@ -96,9 +96,9 @@ describe(`Calendar`, () => {
9696
});
9797

9898
it(`should redisable the next month button when the current month is the same as the maxDate prop`, () => {
99-
let initialDate = new Date();
99+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
100100
let maxDate = new Date(initialDate.toDateString());
101-
maxDate.setMonth(maxDate.getMonth() + 1);
101+
maxDate = DateTime.addMonths(maxDate, 1);
102102

103103
let render = TestUtils.renderIntoDocument(
104104
<ThemedCalendar
@@ -120,7 +120,7 @@ describe(`Calendar`, () => {
120120

121121
describe('Previous Month Button', () => {
122122
it(`should initially disable the previous month button if the current month is the same as the minDate month prop`, () => {
123-
let initialDate = new Date();
123+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
124124
let minDate = new Date(initialDate.toDateString());
125125

126126
let render = TestUtils.renderIntoDocument(
@@ -137,9 +137,9 @@ describe(`Calendar`, () => {
137137
});
138138

139139
it(`should initially disable the previous month button if the current month is before the minDate month prop`, () => {
140-
let initialDate = new Date();
140+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
141141
let minDate = new Date(initialDate.toDateString());
142-
minDate.setMonth(initialDate.getMonth() + 1);
142+
minDate = DateTime.addMonths(initialDate, 1);
143143

144144
let render = TestUtils.renderIntoDocument(
145145
<ThemedCalendar
@@ -155,9 +155,9 @@ describe(`Calendar`, () => {
155155
});
156156

157157
it(`should initially enable the previous month button if the current month is after the minDate month prop`, () => {
158-
let initialDate = new Date();
158+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
159159
let minDate = new Date(initialDate.toDateString());
160-
minDate.setMonth(initialDate.getMonth() - 1);
160+
minDate = DateTime.addMonths(initialDate, -1);
161161

162162
let render = TestUtils.renderIntoDocument(
163163
<ThemedCalendar
@@ -173,7 +173,7 @@ describe(`Calendar`, () => {
173173
});
174174

175175
it(`should enable the previous month button when the current month is after the minDate month prop`, () => {
176-
let initialDate = new Date();
176+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
177177
let minDate = new Date(initialDate.toDateString());
178178

179179
let render = TestUtils.renderIntoDocument(
@@ -193,9 +193,9 @@ describe(`Calendar`, () => {
193193
});
194194

195195
it(`should disable the previous month button when the current month is the same as the minDate month prop`, () => {
196-
let initialDate = new Date();
196+
let initialDate = new Date(1448967059892); // Tue, 01 Dec 2015 10:50:59 GMT
197197
let minDate = new Date(initialDate.toDateString());
198-
minDate.setMonth(minDate.getMonth() - 1);
198+
minDate = DateTime.addMonths(minDate, -1);
199199

200200
let render = TestUtils.renderIntoDocument(
201201
<ThemedCalendar

0 commit comments

Comments
 (0)