mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-09 06:06:51 +00:00
test: add tests for external-link
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
310b908e2d
commit
572f200c99
2 changed files with 110 additions and 0 deletions
|
@ -0,0 +1,77 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`ExternalLink renders an external link correctly 1`] = `
|
||||
<div>
|
||||
<a
|
||||
class="text-light"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
testText
|
||||
</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`ExternalLink renders an external link with a title 1`] = `
|
||||
<div>
|
||||
<a
|
||||
class="text-light"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
title="testTitle"
|
||||
>
|
||||
testText
|
||||
</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`ExternalLink renders an external link with additional className 1`] = `
|
||||
<div>
|
||||
<a
|
||||
class="testClass"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
testText
|
||||
</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`ExternalLink renders an external link with an icon 1`] = `
|
||||
<div>
|
||||
<a
|
||||
class="text-light"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<i
|
||||
class="fa fa-fw fa-heart "
|
||||
/>
|
||||
|
||||
testText
|
||||
</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`ExternalLink renders an external link with an id 1`] = `
|
||||
<div>
|
||||
<a
|
||||
class="text-light"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
id="testId"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
testText
|
||||
</a>
|
||||
</div>
|
||||
`;
|
33
src/components/common/links/external-link.test.tsx
Normal file
33
src/components/common/links/external-link.test.tsx
Normal 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 { ExternalLink } from './external-link'
|
||||
|
||||
describe('ExternalLink', () => {
|
||||
const href = 'https://example.com'
|
||||
const text = 'testText'
|
||||
it('renders an external link correctly', () => {
|
||||
const view = render(<ExternalLink text={text} href={href} />)
|
||||
expect(view.container).toMatchSnapshot()
|
||||
})
|
||||
it('renders an external link with an icon', () => {
|
||||
const view = render(<ExternalLink text={text} href={href} icon={'heart'} />)
|
||||
expect(view.container).toMatchSnapshot()
|
||||
})
|
||||
it('renders an external link with an id', () => {
|
||||
const view = render(<ExternalLink text={text} href={href} id={'testId'} />)
|
||||
expect(view.container).toMatchSnapshot()
|
||||
})
|
||||
it('renders an external link with additional className', () => {
|
||||
const view = render(<ExternalLink text={text} href={href} className={'testClass'} />)
|
||||
expect(view.container).toMatchSnapshot()
|
||||
})
|
||||
it('renders an external link with a title', () => {
|
||||
const view = render(<ExternalLink text={text} href={href} title={'testTitle'} />)
|
||||
expect(view.container).toMatchSnapshot()
|
||||
})
|
||||
})
|
Loading…
Add table
Reference in a new issue