-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for Jest asymmetric matchers and more #148
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,11 +1,19 @@ | ||
interface AsymmetricMatcher { | ||
$$typeof: Symbol; | ||
sample?: string | RegExp | object | Array<any>, Function; | ||
} | ||
|
||
type Value = string | RegExp | AsymmetricMatcher | undefined | ||
|
||
interface Options { | ||
media?: string; | ||
modifier?: string; | ||
supports?: string; | ||
} | ||
|
||
declare namespace jest { | ||
interface Options { | ||
media?: string; | ||
modifier?: string; | ||
supports?: string; | ||
} | ||
|
||
interface Matchers<R> { | ||
toHaveStyleRule(property: string, value: string | RegExp, options?: Options): R; | ||
toHaveStyleRule(property: string, value: Value, options?: Options): R; | ||
} | ||
} |
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
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
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
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,10 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`message when property not found 1`] = `"Property not found: [31m\\"a\\"[39m"`; | ||
exports[`message when property not found 1`] = ` | ||
"[31m\\"Property 'background-color' not found in style rules\\"[39m | ||
|
||
Expected | ||
[32m\\"background-color: black\\"[39m | ||
Received: | ||
[31m\\"background-color: undefined\\"[39m" | ||
`; | ||
|
||
exports[`message when rules not found 1`] = `"No style rules found on passed Component"`; | ||
|
||
exports[`message when rules not found using options 1`] = ` | ||
"No style rules found on passed Component using options: | ||
{\\"media\\":\\"(max-width:640px)\\",\\"modifier\\":\\":hover\\"}" | ||
`; | ||
|
||
exports[`message when value does not match 1`] = ` | ||
"Expected background to match: | ||
[32m\\"red\\"[39m | ||
"[31m\\"Value mismatch for property 'background'\\"[39m | ||
|
||
Expected | ||
[32m\\"background: red\\"[39m | ||
Received: | ||
[31m\\"orange\\"[39m" | ||
[31m\\"background: orange\\"[39m" | ||
`; |
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,10 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`message when property not found 1`] = ` | ||
"[31m\\"Property 'color' not found in style rules\\"[39m | ||
|
||
Expected | ||
[32m\\"color: black\\"[39m | ||
Received: | ||
[31m\\"color: undefined\\"[39m" | ||
`; | ||
|
||
exports[`message when value does not match 1`] = ` | ||
"[2mexpect([22m[31mreceived[39m[2m).toHaveStyleRule([22m[32mexpected[39m[2m)[22m | ||
"[31m\\"Value mismatch for property 'background-color'\\"[39m | ||
|
||
Expected View to have a style rule: | ||
[32m\\"background: red\\"[39m | ||
Expected | ||
[32m\\"background-color: red\\"[39m | ||
Received: | ||
[31m\\"background isn't in the style rules\\"[39m" | ||
[31m\\"background-color: orange\\"[39m" | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to implement following your suggestion, however I usually try to avoid "if statements" when they're not strictly required and in this case I did definitely prefer a simple ternary which also allowed to take advantage of ES6 arrow function implicit return as opposed to open a block.