Skip to content

Commit c3501ce

Browse files
authored
Merge pull request #143 from onefinestay/fix-broken-weekend-date-tests
Fix broken weekend date tests
2 parents ccdaaba + 9e06530 commit c3501ce

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/calendar/tests/CalendarDate.spec.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import CalendarSelection from '../CalendarSelection';
1212

1313

1414
describe('The CalendarDate Component', function () {
15+
const today = () => moment("2014-01-01T12:00:00Z");
1516

1617
beforeEach(function () {
1718

1819
const getCalendarDate = (props) => {
1920

2021
props = _.extend({
21-
date: moment(),
22-
firstOfMonth: moment(),
22+
date: today(),
23+
firstOfMonth: today(),
2324
dateRangesForDate: function () {
2425
return {
2526
count: function () {
@@ -86,21 +87,19 @@ describe('The CalendarDate Component', function () {
8687

8788
describe('sets the correct class', function () {
8889

89-
it('by defininig the expected class name', function () {
90+
it('by defining the expected class name', function () {
9091
this.useShallowRenderer();
9192
expect(this.renderedComponent.props.className).toEqual('DateRangePicker__Date');
9293
});
9394

9495
describe('by setting the expected bem modifiers', function () {
95-
9696
it('when the provided date is today', function () {
9797
this.useShallowRenderer({
9898
isToday: true,
9999
});
100100
expect(this.renderedComponent.props.className).toEqual('DateRangePicker__Date DateRangePicker__Date--today');
101101
});
102102

103-
104103
it('when the provided date is not today', function () {
105104
this.useShallowRenderer({
106105
isToday: false,
@@ -109,7 +108,7 @@ describe('The CalendarDate Component', function () {
109108
});
110109

111110
it('when the provided date is over the weekend', function () {
112-
var nextSunday = moment().day(7);
111+
var nextSunday = today().day(7);
113112
this.useShallowRenderer({
114113
date: nextSunday,
115114
});
@@ -118,16 +117,16 @@ describe('The CalendarDate Component', function () {
118117

119118

120119
it('when the provided date is not over the weekend', function () {
121-
let nextMonday = moment().day(8);
120+
let nextMonday = today().day(8);
122121
this.useShallowRenderer({
123122
date: nextMonday,
124123
});
125124
expect(this.renderedComponent.props.className).not.toContain('DateRangePicker__Date--weekend');
126125
});
127126

128127
it('when the provided date is during the same month', function () {
129-
let date = moment().date(8).month(3),
130-
firstOfMonth = moment().date(1).month(3);
128+
let date = today().date(8).month(3),
129+
firstOfMonth = today().date(1).month(3);
131130
this.useShallowRenderer({
132131
date: date,
133132
firstOfMonth: firstOfMonth,
@@ -137,8 +136,8 @@ describe('The CalendarDate Component', function () {
137136

138137

139138
it('when the provided date is not during the same month', function () {
140-
let date = moment().date(8).month(3),
141-
firstOfMonth = moment().date(1).month(43);
139+
let date = today().date(8).month(3),
140+
firstOfMonth = today().date(1).month(43);
142141
this.useShallowRenderer({
143142
date: date,
144143
firstOfMonth: firstOfMonth,
@@ -255,7 +254,7 @@ describe('The CalendarDate Component', function () {
255254
//Workaround as suggested from https://github.com/facebook/react/issues/1297
256255

257256
beforeEach(function(){
258-
this.date = moment();
257+
this.date = today();
259258
this.useDocumentRenderer({
260259
date: this.date,
261260
});

0 commit comments

Comments
 (0)