test: add tests for internal-link

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-05-22 10:22:55 +02:00 committed by Tilman Vatteroth
parent 572f200c99
commit 5025d50e9e
2 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`InternalLink renders an internal link correctly 1`] = `
<div>
<a
class="text-light"
href="/test"
>
testText
</a>
</div>
`;
exports[`InternalLink renders an internal link with a title 1`] = `
<div>
<a
class="text-light"
href="/test"
title="testTitle"
>
testText
</a>
</div>
`;
exports[`InternalLink renders an internal link with additional className 1`] = `
<div>
<a
class="testClass"
href="/test"
>
testText
</a>
</div>
`;
exports[`InternalLink renders an internal link with an icon 1`] = `
<div>
<a
class="text-light"
href="/test"
>
<i
class="fa fa-fw fa-heart "
/>
 
testText
</a>
</div>
`;
exports[`InternalLink renders an internal link with an id 1`] = `
<div>
<a
class="text-light"
href="/test"
id="testId"
>
testText
</a>
</div>
`;

View file

@ -0,0 +1,33 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { render } from '@testing-library/react'
import { InternalLink } from './internal-link'
describe('InternalLink', () => {
const href = '/test'
const text = 'testText'
it('renders an internal link correctly', () => {
const view = render(<InternalLink text={text} href={href} />)
expect(view.container).toMatchSnapshot()
})
it('renders an internal link with an icon', () => {
const view = render(<InternalLink text={text} href={href} icon={'heart'} />)
expect(view.container).toMatchSnapshot()
})
it('renders an internal link with an id', () => {
const view = render(<InternalLink text={text} href={href} id={'testId'} />)
expect(view.container).toMatchSnapshot()
})
it('renders an internal link with additional className', () => {
const view = render(<InternalLink text={text} href={href} className={'testClass'} />)
expect(view.container).toMatchSnapshot()
})
it('renders an internal link with a title', () => {
const view = render(<InternalLink text={text} href={href} title={'testTitle'} />)
expect(view.container).toMatchSnapshot()
})
})