From 572f200c99423f2d50575802990833b2f7151ef5 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sun, 22 May 2022 10:22:33 +0200 Subject: [PATCH] test: add tests for external-link Signed-off-by: Philip Molares --- .../__snapshots__/external-link.test.tsx.snap | 77 +++++++++++++++++++ .../common/links/external-link.test.tsx | 33 ++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/components/common/links/__snapshots__/external-link.test.tsx.snap create mode 100644 src/components/common/links/external-link.test.tsx diff --git a/src/components/common/links/__snapshots__/external-link.test.tsx.snap b/src/components/common/links/__snapshots__/external-link.test.tsx.snap new file mode 100644 index 000000000..c7c28b6f6 --- /dev/null +++ b/src/components/common/links/__snapshots__/external-link.test.tsx.snap @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ExternalLink renders an external link correctly 1`] = ` +
+ + testText + +
+`; + +exports[`ExternalLink renders an external link with a title 1`] = ` +
+ + testText + +
+`; + +exports[`ExternalLink renders an external link with additional className 1`] = ` +
+ + testText + +
+`; + +exports[`ExternalLink renders an external link with an icon 1`] = ` +
+ + +   + testText + +
+`; + +exports[`ExternalLink renders an external link with an id 1`] = ` +
+ + testText + +
+`; diff --git a/src/components/common/links/external-link.test.tsx b/src/components/common/links/external-link.test.tsx new file mode 100644 index 000000000..8218933aa --- /dev/null +++ b/src/components/common/links/external-link.test.tsx @@ -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() + expect(view.container).toMatchSnapshot() + }) + it('renders an external link with an icon', () => { + const view = render() + expect(view.container).toMatchSnapshot() + }) + it('renders an external link with an id', () => { + const view = render() + expect(view.container).toMatchSnapshot() + }) + it('renders an external link with additional className', () => { + const view = render() + expect(view.container).toMatchSnapshot() + }) + it('renders an external link with a title', () => { + const view = render() + expect(view.container).toMatchSnapshot() + }) +})