Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Condense
toBeBefore
matcher into one file
- Loading branch information
1 parent
83edb9b
commit 0614907
Showing
6 changed files
with
24 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function toBeBefore(actual, expected) { | ||
const { matcherHint, printReceived } = this.utils; | ||
const passMessage = () => | ||
matcherHint('.not.toBeBefore', 'received', '') + | ||
'\n\n' + | ||
`Expected date to be before ${printReceived(actual)} but received:\n` + | ||
` ${printReceived(expected)}`; | ||
|
||
const failMessage = () => | ||
matcherHint('.toBeBefore', 'received', '') + | ||
'\n\n' + | ||
`Expected date to be before ${printReceived(actual)} but received:\n` + | ||
` ${printReceived(expected)}`; | ||
|
||
const pass = actual < expected; | ||
const message = pass ? passMessage : failMessage; | ||
|
||
return { pass, message }; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/matchers/toBeBefore/index.test.js → test/matchers/toBeBefore.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as matcher from './'; | ||
import * as matcher from 'src/matchers/toBeBefore'; | ||
|
||
expect.extend(matcher); | ||
|
||
|