-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Condense
toBeArrayOfSize
matcher into one file
- Loading branch information
1 parent
7e6a1f6
commit 83edb9b
Showing
6 changed files
with
107 additions
and
136 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,28 @@ | ||
import { determinePropertyMessage } from '../utils'; | ||
|
||
export function toBeArrayOfSize(actual, expected) { | ||
const { printExpected, printReceived, matcherHint } = this.utils; | ||
|
||
const passMessage = () => | ||
`${matcherHint('.not.toBeArrayOfSize')} | ||
Expected value to not be an array of size: | ||
${printExpected(expected)} | ||
Received: | ||
value: ${printReceived(actual)} | ||
length: ${printReceived(determinePropertyMessage(actual, 'length'))}`; | ||
|
||
const failMessage = () => | ||
`${matcherHint('.toBeArrayOfSize')} | ||
Expected value to be an array of size: | ||
${printExpected(expected)} | ||
Received: | ||
value: ${printReceived(actual)} | ||
length: ${printReceived(determinePropertyMessage(actual, 'length'))}`; | ||
|
||
const pass = Array.isArray(actual) && actual.length === 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/toBeArrayOfSize/index.test.js → test/matchers/toBeArrayOfSize.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/toBeArrayOfSize'; | ||
|
||
expect.extend(matcher); | ||
|
||
|