-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathtoHaveDateBefore.spec.js
35 lines (34 loc) · 1015 Bytes
/
toHaveDateBefore.spec.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
const describeToHaveX = require('./lib/describeToHaveX');
describeToHaveX('toHaveDateBefore', () => {
let mockDate;
beforeEach(() => {
mockDate = {
any: new Date(),
early: new Date('2013-01-01T00:00:00.000Z'),
late: new Date('2013-01-01T01:00:00.000Z')
};
});
describe('when member is an instance of Date', () => {
describe('when date occurs before another', () => {
it('should confirm', () => {
expect({
memberName: mockDate.early
}).toHaveDateBefore('memberName', mockDate.late);
});
});
describe('when date does NOT occur before another', () => {
it('should deny', () => {
expect({
memberName: mockDate.late
}).not.toHaveDateBefore('memberName', mockDate.early);
});
});
});
describe('when member is NOT an instance of Date', () => {
it('should deny', () => {
expect({
memberName: null
}).not.toHaveDateBefore('memberName', mockDate.any);
});
});
});