forked from styled-components/jest-styled-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for Jest asymmetric matchers and more (styled-componen…
…ts#148) * Adding support for matching against Jest asymmetric matchers and 'undefined' also implementing consistent messages across react and react native as well as fixing skipped and broken react native tests * updating ts definitions
- Loading branch information
1 parent
b4bac45
commit 0d4c0ea
Showing
9 changed files
with
269 additions
and
96 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
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.