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