Skip to content

Commit

Permalink
Condense toBeBeforeOrEqualTo matcher into one file
Browse files Browse the repository at this point in the history
  • Loading branch information
mattphillips committed Jan 31, 2022
1 parent 0614907 commit c8a26ee
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 46 deletions.
20 changes: 20 additions & 0 deletions src/matchers/toBeBeforeOrEqualTo.js
@@ -0,0 +1,20 @@
export function toBeBeforeOrEqualTo(actual, expected) {
const { matcherHint, printReceived } = this.utils;

const passMessage = () =>
matcherHint('.not.toBeBeforeOrEqualTo', 'received', '') +
'\n\n' +
`Expected date to be before or equal to ${printReceived(expected)} but received:\n` +
` ${printReceived(actual)}`;

const failMessage = () =>
matcherHint('.toBeBeforeOrEqualTo', 'received', '') +
'\n\n' +
`Expected date to be before or equal to ${printReceived(expected)} but received:\n` +
` ${printReceived(actual)}`;

const pass = actual <= expected;
const message = pass ? passMessage : failMessage;

return { pass, message };
}
22 changes: 0 additions & 22 deletions src/matchers/toBeBeforeOrEqualTo/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/matchers/toBeBeforeOrEqualTo/predicate.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/matchers/toBeBeforeOrEqualTo/predicate.test.js

This file was deleted.

@@ -1,4 +1,4 @@
import * as matcher from './';
import * as matcher from 'src/matchers/toBeBeforeOrEqualTo';

expect.extend(matcher);

Expand Down

0 comments on commit c8a26ee

Please sign in to comment.