-
-
Notifications
You must be signed in to change notification settings - Fork 214
/
index.js
22 lines (18 loc) 路 930 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import predicate from './predicate';
const passMessage = (utils, received, startDate, endDate) => () =>
utils.matcherHint('.not.toBeBetween', 'received', '') +
'\n\n' +
`Expected date to be between ${utils.printReceived(startDate)} and ${utils.printReceived(endDate)} but received:\n` +
` ${utils.printReceived(received)}`;
const failMessage = (utils, received, startDate, endDate) => () =>
utils.matcherHint('.toBeBetween', 'received', '') +
'\n\n' +
`Expected date to be between ${utils.printReceived(startDate)} and ${utils.printReceived(endDate)} but received:\n` +
` ${utils.printReceived(received)}`;
export function toBeBetween(date, startDate, endDate) {
const pass = predicate(date, startDate, endDate);
if (pass) {
return { pass: true, message: passMessage(this.utils, date, startDate, endDate) };
}
return { pass: false, message: failMessage(this.utils, date, startDate, endDate) };
}