Skip to content

Commit 627627a

Browse files
Ricardo Lopesricardobcl
authored andcommitted
Fix date tests on node 10
1 parent 79ec420 commit 627627a

4 files changed

+32
-32
lines changed

test/asserts/date-diff-greater-than-assert_test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('DateDiffGreaterThanAssert', () => {
150150

151151
it('should throw an error if the diff between `fromDate` and input date is less than the `threshold`', () => {
152152
try {
153-
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000, { fromDate: new Date('1970-01-01 00:00:00') }).validate(new Date('1970-01-01 10:00:00'));
153+
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000, { fromDate: new Date('1970-01-01') }).validate(new Date('1970-01-01 10:00:00Z'));
154154

155155
should.fail();
156156
} catch (e) {
@@ -208,7 +208,7 @@ describe('DateDiffGreaterThanAssert', () => {
208208

209209
it('should use the `asFloat` option supplied', () => {
210210
try {
211-
new Assert().DateDiffGreaterThan(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00'), unit: 'minutes' }).validate(new Date('1970-01-01 10:04:51'));
211+
new Assert().DateDiffGreaterThan(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'minutes' }).validate(new Date('1970-01-01 10:04:51Z'));
212212

213213
should.fail();
214214
} catch (e) {
@@ -219,7 +219,7 @@ describe('DateDiffGreaterThanAssert', () => {
219219

220220
it('should use the `unit` option supplied', () => {
221221
try {
222-
new Assert().DateDiffGreaterThan(2000, { fromDate: new Date('1970-01-01 10:00:00'), unit: 'seconds' }).validate(new Date('1970-01-01 10:00:05'));
222+
new Assert().DateDiffGreaterThan(2000, { fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'seconds' }).validate(new Date('1970-01-01 10:00:05Z'));
223223

224224
should.fail();
225225
} catch (e) {
@@ -230,24 +230,24 @@ describe('DateDiffGreaterThanAssert', () => {
230230
it('should accept a date whose diff from `now` is greater than the threshold', () => {
231231
const clock = sinon.useFakeTimers(0, 'Date');
232232

233-
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000).validate(new Date('1969-12-30 00:00:00'));
233+
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000).validate(new Date('1969-12-30'));
234234

235235
clock.restore();
236236
});
237237

238238
it('should accept a date whose `absolute` diff from `now` is greater than the threshold', () => {
239239
const clock = sinon.useFakeTimers(0, 'Date');
240240

241-
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-03 00:00:00'));
241+
new Assert().DateDiffGreaterThan(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-03'));
242242

243243
clock.restore();
244244
});
245245

246246
it('should accept a date whose diff from `fromDate` is greater than the threshold', () => {
247-
new Assert().DateDiffGreaterThan(24, { asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1969-12-30 00:00:00'));
247+
new Assert().DateDiffGreaterThan(24, { asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1969-12-30'));
248248
});
249249

250250
it('should accept a date whose `absolute` diff from `fromDate` is greater than the threshold', () => {
251-
new Assert().DateDiffGreaterThan(24, { absolute: true, asFloat: false, fromDate: new Date('1969-12-30 00:00:00'), unit: 'hours' }).validate(new Date('1970-01-01 00:00:00'));
251+
new Assert().DateDiffGreaterThan(24, { absolute: true, asFloat: false, fromDate: new Date('1969-12-30'), unit: 'hours' }).validate(new Date('1970-01-01'));
252252
});
253253
});

test/asserts/date-diff-greater-than-or-equal-to-assert_test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('DateDiffGreaterThanOrEqualToAssert', () => {
9898

9999
it('should throw an error if the diff between `fromDate` and input date is less than the `threshold`', () => {
100100
try {
101-
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { fromDate: new Date('1970-01-01 00:00:00') }).validate(new Date('1970-01-01 10:00:00'));
101+
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { fromDate: new Date('1970-01-01') }).validate(new Date('1970-01-01 10:00:00Z'));
102102

103103
should.fail();
104104
} catch (e) {
@@ -156,7 +156,7 @@ describe('DateDiffGreaterThanOrEqualToAssert', () => {
156156

157157
it('should use the `asFloat` option supplied', () => {
158158
try {
159-
new Assert().DateDiffGreaterThanOrEqualTo(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00'), unit: 'minutes' }).validate(new Date('1970-01-01 10:04:51'));
159+
new Assert().DateDiffGreaterThanOrEqualTo(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'minutes' }).validate(new Date('1970-01-01 10:04:51Z'));
160160

161161
should.fail();
162162
} catch (e) {
@@ -167,7 +167,7 @@ describe('DateDiffGreaterThanOrEqualToAssert', () => {
167167

168168
it('should use the `unit` option supplied', () => {
169169
try {
170-
new Assert().DateDiffGreaterThanOrEqualTo(2000, { fromDate: new Date('1970-01-01 10:00:00'), unit: 'seconds' }).validate(new Date('1970-01-01 10:00:05'));
170+
new Assert().DateDiffGreaterThanOrEqualTo(2000, { fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'seconds' }).validate(new Date('1970-01-01 10:00:05Z'));
171171

172172
should.fail();
173173
} catch (e) {
@@ -178,48 +178,48 @@ describe('DateDiffGreaterThanOrEqualToAssert', () => {
178178
it('should accept a date whose diff from `now` is equal to the threshold', () => {
179179
const clock = sinon.useFakeTimers(0, 'Date');
180180

181-
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 00:00:00'));
181+
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31'));
182182

183183
clock.restore();
184184
});
185185

186186
it('should accept a date whose diff from `now` is greater than the threshold', () => {
187187
const clock = sinon.useFakeTimers(0, 'Date');
188188

189-
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-30 00:00:00'));
189+
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-30'));
190190

191191
clock.restore();
192192
});
193193

194194
it('should accept a date whose `absolute` diff from `now` is equal to the threshold', () => {
195195
const clock = sinon.useFakeTimers(0, 'Date');
196196

197-
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-02 00:00:00'));
197+
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-02'));
198198

199199
clock.restore();
200200
});
201201

202202
it('should accept a date whose `absolute` diff from `now` is greater than the threshold', () => {
203203
const clock = sinon.useFakeTimers(0, 'Date');
204204

205-
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-03 00:00:00'));
205+
new Assert().DateDiffGreaterThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-03'));
206206

207207
clock.restore();
208208
});
209209

210210
it('should accept a date whose diff from `fromDate` is equal to the threshold', () => {
211-
new Assert().DateDiffGreaterThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1969-12-31 00:00:00'));
211+
new Assert().DateDiffGreaterThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1969-12-31'));
212212
});
213213

214214
it('should accept a date whose diff from `fromDate` is greater than the threshold', () => {
215-
new Assert().DateDiffGreaterThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1969-12-30 00:00:00'));
215+
new Assert().DateDiffGreaterThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1969-12-30'));
216216
});
217217

218218
it('should accept a date whose `absolute` diff from `fromDate` is equal to the threshold', () => {
219-
new Assert().DateDiffGreaterThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1970-01-02 00:00:00'));
219+
new Assert().DateDiffGreaterThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1970-01-02'));
220220
});
221221

222222
it('should accept a date whose `absolute` diff from `fromDate` is greater than the threshold', () => {
223-
new Assert().DateDiffGreaterThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1970-01-03 00:00:00'));
223+
new Assert().DateDiffGreaterThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1970-01-03'));
224224
});
225225
});

test/asserts/date-diff-less-than-assert_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe('DateDiffLessThanAssert', () => {
234234

235235
it('should use the `asFloat` option supplied', () => {
236236
try {
237-
new Assert().DateDiffLessThan(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00'), unit: 'minutes' }).validate(new Date('1970-01-01 09:54:57'));
237+
new Assert().DateDiffLessThan(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'minutes' }).validate(new Date('1970-01-01 09:54:57Z'));
238238

239239
should.fail();
240240
} catch (e) {
@@ -244,18 +244,18 @@ describe('DateDiffLessThanAssert', () => {
244244
});
245245

246246
it('should use the `unit` option supplied', () => {
247-
new Assert().DateDiffLessThan(2000, { fromDate: new Date('1970-01-01 10:00:00'), unit: 'seconds' }).validate(new Date('1970-01-01 09:55:55'));
247+
new Assert().DateDiffLessThan(2000, { fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'seconds' }).validate(new Date('1970-01-01 09:55:55Z'));
248248
});
249249

250250
it('should accept a date whose diff from `now` is less than the threshold', () => {
251251
const clock = sinon.useFakeTimers(0, 'Date');
252252

253-
new Assert().DateDiffLessThan(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 11:00:00'));
253+
new Assert().DateDiffLessThan(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 11:00:00Z'));
254254

255255
clock.restore();
256256
});
257257

258258
it('should accept a date whose diff from `fromDate` is less than the threshold', () => {
259-
new Assert().DateDiffLessThan(24, { asFloat: false, fromDate: new Date('1970-01-01 09:00:00'), unit: 'hours' }).validate(new Date('1970-01-01 00:00:00'));
259+
new Assert().DateDiffLessThan(24, { asFloat: false, fromDate: new Date('1970-01-01 09:00:00Z'), unit: 'hours' }).validate(new Date('1970-01-01'));
260260
});
261261
});

test/asserts/date-diff-less-than-or-equal-to-assert_test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ describe('DateDiffLessThanOrEqualToAssert', () => {
182182

183183
it('should use the `asFloat` option supplied', () => {
184184
try {
185-
new Assert().DateDiffLessThanOrEqualTo(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00'), unit: 'minutes' }).validate(new Date('1970-01-01 09:54:57'));
185+
new Assert().DateDiffLessThanOrEqualTo(5, { asFloat: true, fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'minutes' }).validate(new Date('1970-01-01 09:54:57Z'));
186186

187187
should.fail();
188188
} catch (e) {
@@ -192,54 +192,54 @@ describe('DateDiffLessThanOrEqualToAssert', () => {
192192
});
193193

194194
it('should use the `unit` option supplied', () => {
195-
new Assert().DateDiffLessThanOrEqualTo(2000, { fromDate: new Date('1970-01-01 10:00:00'), unit: 'seconds' }).validate(new Date('1970-01-01 09:55:55'));
195+
new Assert().DateDiffLessThanOrEqualTo(2000, { fromDate: new Date('1970-01-01 10:00:00Z'), unit: 'seconds' }).validate(new Date('1970-01-01 09:55:55Z'));
196196
});
197197

198198
it('should accept a date whose diff from `now` is equal to the threshold', () => {
199199
const clock = sinon.useFakeTimers(0, 'Date');
200200

201-
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 00:00:00'));
201+
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31'));
202202

203203
clock.restore();
204204
});
205205

206206
it('should accept a date whose diff from `now` is less than the threshold', () => {
207207
const clock = sinon.useFakeTimers(0, 'Date');
208208

209-
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 11:00:00'));
209+
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000).validate(new Date('1969-12-31 11:00:00Z'));
210210

211211
clock.restore();
212212
});
213213

214214
it('should accept a date whose `absolute` diff from `now` is equal to the threshold', () => {
215215
const clock = sinon.useFakeTimers(0, 'Date');
216216

217-
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-02 00:00:00'));
217+
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-02'));
218218

219219
clock.restore();
220220
});
221221

222222
it('should accept a date whose `absolute` diff from `now` is less than the threshold', () => {
223223
const clock = sinon.useFakeTimers(0, 'Date');
224224

225-
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-01 11:00:00'));
225+
new Assert().DateDiffLessThanOrEqualTo(24 * 60 * 60 * 1000, { absolute: true }).validate(new Date('1970-01-01 11:00:00Z'));
226226

227227
clock.restore();
228228
});
229229

230230
it('should accept a date whose diff from `fromDate` is equal to the threshold', () => {
231-
new Assert().DateDiffLessThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1969-12-31 00:00:00'));
231+
new Assert().DateDiffLessThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1969-12-31'));
232232
});
233233

234234
it('should accept a date whose diff from `fromDate` is less than the threshold', () => {
235-
new Assert().DateDiffLessThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1969-12-31 11:00:00'));
235+
new Assert().DateDiffLessThanOrEqualTo(24, { asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1969-12-31 11:00:00Z'));
236236
});
237237

238238
it('should accept a date whose `absolute` diff from `fromDate` is equal to the threshold', () => {
239-
new Assert().DateDiffLessThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1970-01-02 00:00:00'));
239+
new Assert().DateDiffLessThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1970-01-02'));
240240
});
241241

242242
it('should accept a date whose `absolute` diff from `fromDate` is less than the threshold', () => {
243-
new Assert().DateDiffLessThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01 00:00:00'), unit: 'hours' }).validate(new Date('1970-01-01 11:00:00'));
243+
new Assert().DateDiffLessThanOrEqualTo(24, { absolute: true, asFloat: false, fromDate: new Date('1970-01-01'), unit: 'hours' }).validate(new Date('1970-01-01 11:00:00Z'));
244244
});
245245
});

0 commit comments

Comments
 (0)