test: add tests for show-if

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-05-21 16:26:47 +02:00 committed by Tilman Vatteroth
parent a8673c9174
commit f557901944
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ShowIf does not render child if condition is false 1`] = `<div />`;
exports[`ShowIf renders child if condition is true 1`] = `
<div>
test
</div>
`;

View file

@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { render } from '@testing-library/react'
import { ShowIf } from './show-if'
describe('ShowIf', () => {
it('renders child if condition is true', () => {
const view = render(<ShowIf condition={true}>test</ShowIf>)
expect(view.container).toMatchSnapshot()
})
it('does not render child if condition is false', () => {
const view = render(<ShowIf condition={false}>test</ShowIf>)
expect(view.container).toMatchSnapshot()
})
})