import * as React from 'react'
import {render, screen} from '../'
beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation(() => {})
})
afterEach(() => {
console.log.mockRestore()
})
test('debug pretty prints the container', () => {
const HelloWorld = () =>
Hello World
const {debug} = render()
debug()
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Hello World'),
)
})
test('debug pretty prints multiple containers', () => {
const HelloWorld = () => (
<>
Hello World
Hello World
>
)
const {debug} = render()
const multipleElements = screen.getAllByTestId('testId')
debug(multipleElements)
expect(console.log).toHaveBeenCalledTimes(2)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Hello World'),
)
})
test('allows same arguments as prettyDOM', () => {
const HelloWorld = () => Hello World
const {debug, container} = render()
debug(container, 6, {highlight: false})
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
[
...,
]
`)
})
/*
eslint
no-console: "off",
*/