-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
280 additions
and
61 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 |
---|---|---|
@@ -0,0 +1,198 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`.toBeInTheDOM 1`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toBeInTheDOM(</><dim>)</> | ||
Received: | ||
<red><span data-testid=\\"count-value\\" /></>" | ||
`; | ||
exports[`.toBeInTheDOM 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).toBeInTheDOM(</><dim>)</> | ||
Received: | ||
<red>null</>" | ||
`; | ||
exports[`.toBeInTheDOM 3`] = ` | ||
"<dim>expect(</><red>received</><dim>).toBeInTheDOM(</><dim>)</> | ||
<red>received</> value must be an HTMLElement. | ||
Received: | ||
object: <red>{\\"thisIsNot\\": \\"an html element\\"}</>" | ||
`; | ||
exports[`.toBeVisible 1`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toBeVisible(</><dim>)</> | ||
Received element is visible: | ||
<red><header /></>" | ||
`; | ||
exports[`.toBeVisible 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).toBeVisible(</><dim>)</> | ||
Received element is not visible: | ||
<red><p /></>" | ||
`; | ||
exports[`.toHaveAttribute 1`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveAttribute(</><green><green>\\"disabled\\"<green></><dim>) // element.hasAttribute(\\"disabled\\")</> | ||
Expected the element not to have attribute: | ||
<green> disabled</> | ||
Received: | ||
<red> disabled=\\"\\"</>" | ||
`; | ||
exports[`.toHaveAttribute 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveAttribute(</><green><green>\\"type\\"<green></><dim>) // element.hasAttribute(\\"type\\")</> | ||
Expected the element not to have attribute: | ||
<green> type</> | ||
Received: | ||
<red> type=\\"submit\\"</>" | ||
`; | ||
exports[`.toHaveAttribute 3`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveAttribute(</><green><green>\\"class\\"<green></><dim>) // element.hasAttribute(\\"class\\")</> | ||
Expected the element to have attribute: | ||
<green> class</> | ||
Received: | ||
<red> null</>" | ||
`; | ||
exports[`.toHaveAttribute 4`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveAttribute(</><green><green>\\"type\\"<green></><dim>, </><green><green>\\"submit\\"<green></><dim>) // element.getAttribute(\\"type\\") === \\"submit\\"</> | ||
Expected the element not to have attribute: | ||
<green> type=\\"submit\\"</> | ||
Received: | ||
<red> type=\\"submit\\"</>" | ||
`; | ||
exports[`.toHaveAttribute 5`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveAttribute(</><green><green>\\"type\\"<green></><dim>, </><green><green>\\"button\\"<green></><dim>) // element.getAttribute(\\"type\\") === \\"button\\"</> | ||
Expected the element to have attribute: | ||
<green> type=\\"button\\"</> | ||
Received: | ||
<red> type=\\"submit\\"</>" | ||
`; | ||
exports[`.toHaveAttribute 6`] = ` | ||
"<dim>expect(</><red>received</><dim>).not.toHaveAttribute(</><dim>)</> | ||
<red>received</> value must be an HTMLElement. | ||
Received: | ||
object: <red>{\\"thisIsNot\\": \\"an html element\\"}</>" | ||
`; | ||
exports[`.toHaveClass 1`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveClass(</><green><green>\\"btn\\"<green></><dim>)</> | ||
Expected the element not to have class: | ||
<green> btn</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveClass(</><green><green>\\"btn-danger\\"<green></><dim>)</> | ||
Expected the element not to have class: | ||
<green> btn-danger</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 3`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveClass(</><green><green>\\"extra\\"<green></><dim>)</> | ||
Expected the element not to have class: | ||
<green> extra</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 4`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveClass(</><green><green>\\"xtra\\"<green></><dim>)</> | ||
Expected the element to have class: | ||
<green> xtra</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 5`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveClass(</><green><green>\\"btn btn-danger\\"<green></><dim>)</> | ||
Expected the element not to have class: | ||
<green> btn btn-danger</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 6`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveClass(</><green><green>\\"btn-link\\"<green></><dim>)</> | ||
Expected the element to have class: | ||
<green> btn-link</> | ||
Received: | ||
<red> btn extra btn-danger</>" | ||
`; | ||
exports[`.toHaveClass 7`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveClass(</><green><green>\\"btn-danger\\"<green></><dim>)</> | ||
Expected the element to have class: | ||
<green> btn-danger</> | ||
Received: | ||
" | ||
`; | ||
exports[`.toHaveStyle 1`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveStyle(</><dim>)</> | ||
<green>- Expected</> | ||
<green>- font-weight: bold;</> | ||
<dim> </> | ||
<red>+ </>" | ||
`; | ||
exports[`.toHaveStyle 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveStyle(</><dim>)</> | ||
<dim>Compared values have no visual difference.</>" | ||
`; | ||
exports[`.toHaveStyle 3`] = `"Syntax error parsing expected css: property missing ':' in 1:24"`; | ||
exports[`.toHaveStyle 4`] = `"Syntax error parsing expected css: property missing ':' in 1:18"`; | ||
exports[`.toHaveTextContent 1`] = ` | ||
"<dim>expect(</><red>received</><dim>).toHaveTextContent(</><dim>)</> | ||
<red>received</> value must be an HTMLElement. | ||
Received: <red>null</>" | ||
`; | ||
exports[`.toHaveTextContent 2`] = ` | ||
"<dim>expect(</><red>element</><dim>).toHaveTextContent(</><dim>)</> | ||
Expected element to have text content: | ||
<green> 3</> | ||
Received: | ||
<red> 2</>" | ||
`; | ||
exports[`.toHaveTextContent 3`] = ` | ||
"<dim>expect(</><red>element</><dim>).not.toHaveTextContent(</><dim>)</> | ||
Expected element not to have text content: | ||
<green> 2</> | ||
Received: | ||
<red> 2</>" | ||
`; |
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,21 +1,19 @@ | ||
import {matcherHint} from 'jest-matcher-utils' | ||
import {checkHtmlElement, getMessage} from './utils' | ||
import {matcherHint, printReceived} from 'jest-matcher-utils' | ||
import {checkHtmlElement} from './utils' | ||
|
||
export function toBeInTheDOM(received) { | ||
if (received) { | ||
checkHtmlElement(received) | ||
checkHtmlElement(received, toBeInTheDOM, this) | ||
} | ||
return { | ||
pass: !!received, | ||
message: () => { | ||
const to = this.isNot ? 'not to' : 'to' | ||
return getMessage( | ||
return [ | ||
matcherHint(`${this.isNot ? '.not' : ''}.toBeInTheDOM`, 'element', ''), | ||
'Expected', | ||
`element ${to} be present`, | ||
'Received', | ||
received, | ||
) | ||
'', | ||
'Received:', | ||
` ${printReceived(received ? received.cloneNode(false) : received)}`, | ||
].join('\n') | ||
}, | ||
} | ||
} |
Oops, something went wrong.