-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
They hide console logs which we shouldn't do for pretty-dom since that shouldn't console.log in the first place
- Loading branch information
Showing
2 changed files
with
57 additions
and
55 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,56 @@ | ||
import {getUserCodeFrame} from '../get-user-code-frame' | ||
import {logDOM} from '../pretty-dom' | ||
import {render} from './helpers/test-utils' | ||
|
||
jest.mock('../get-user-code-frame') | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'log').mockImplementation(() => {}) | ||
}) | ||
|
||
afterEach(() => { | ||
console.log.mockRestore() | ||
}) | ||
|
||
test('logDOM logs prettyDOM to the console', () => { | ||
const {container} = render('<div>Hello World!</div>') | ||
logDOM(container) | ||
expect(console.log).toHaveBeenCalledTimes(1) | ||
expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
<div> | ||
<div> | ||
Hello World! | ||
</div> | ||
</div> | ||
`) | ||
}) | ||
|
||
test('logDOM logs prettyDOM with code frame to the console', () => { | ||
getUserCodeFrame.mockImplementationOnce( | ||
() => `"/home/john/projects/sample-error/error-example.js:7:14 | ||
5 | document.createTextNode('Hello World!') | ||
6 | ) | ||
> 7 | screen.debug() | ||
| ^ | ||
" | ||
`, | ||
) | ||
const {container} = render('<div>Hello World!</div>') | ||
logDOM(container) | ||
expect(console.log).toHaveBeenCalledTimes(1) | ||
expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
<div> | ||
<div> | ||
Hello World! | ||
</div> | ||
</div> | ||
"/home/john/projects/sample-error/error-example.js:7:14 | ||
5 | document.createTextNode('Hello World!') | ||
6 | ) | ||
> 7 | screen.debug() | ||
| ^ | ||
" | ||
`) | ||
}) |
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