2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-09-08 12:02:29 +02:00
|
|
|
const isoDateRegex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
|
|
|
|
|
2021-03-29 12:33:08 +02:00
|
|
|
jest.setTimeout(60000);
|
2021-03-26 20:15:38 +01:00
|
|
|
|
2020-05-18 20:39:39 +02:00
|
|
|
expect.extend({
|
|
|
|
stringOrNull(received) {
|
|
|
|
const pass = typeof received === 'string' || received === null;
|
2020-09-08 12:02:29 +02:00
|
|
|
return {
|
|
|
|
message: () => `expected ${received} ${pass ? 'not ' : ''}to be null or a string`,
|
|
|
|
pass,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
toBeISODate(received) {
|
|
|
|
const pass = isoDateRegex.test(received) && new Date(received).toISOString() === received;
|
|
|
|
return {
|
|
|
|
pass,
|
|
|
|
message: () => `Expected ${received} ${pass ? 'not ' : ''}to be a valid ISO date string`,
|
|
|
|
};
|
2020-05-18 20:39:39 +02:00
|
|
|
},
|
|
|
|
});
|