test: add tests for translated-icon-button

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-05-22 17:40:31 +02:00 committed by Tilman Vatteroth
parent 5025d50e9e
commit 857f808893
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`TranslatedIconButton renders heart icon with i18nKey 1`] = `
<div>
<button
class="btn-icon p-0 d-inline-flex align-items-stretch btn btn-primary"
data-testid="icon-button"
type="button"
>
<span
class="icon-part d-flex align-items-center"
>
<i
class="fa fa-heart icon "
/>
</span>
<span
class="text-part d-flex align-items-center"
>
testi18nKey
</span>
</button>
</div>
`;

View file

@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { mockI18n } from '../../markdown-renderer/test-utils/mock-i18n'
import { render } from '@testing-library/react'
import { TranslatedIconButton } from './translated-icon-button'
describe('TranslatedIconButton', () => {
it('renders heart icon with i18nKey', async () => {
await mockI18n()
const view = render(<TranslatedIconButton i18nKey={'testi18nKey'} icon={'heart'} />)
expect(view.container).toMatchSnapshot()
})
})