From 5162fa2a13b7a161deaa7868ba499019bb1528e8 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 19 Dec 2022 20:27:33 +0100 Subject: [PATCH] Created Tags test --- test/short-urls/helpers/Tags.test.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/short-urls/helpers/Tags.test.tsx diff --git a/test/short-urls/helpers/Tags.test.tsx b/test/short-urls/helpers/Tags.test.tsx new file mode 100644 index 00000000..f2edd302 --- /dev/null +++ b/test/short-urls/helpers/Tags.test.tsx @@ -0,0 +1,22 @@ +import { render, screen } from '@testing-library/react'; +import { Tags } from '../../../src/short-urls/helpers/Tags'; +import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock'; + +describe('', () => { + const setUp = (tags: string[]) => render(); + + it('returns no tags when the list is empty', () => { + setUp([]); + expect(screen.getByText('No tags')).toBeInTheDocument(); + }); + + it.each([ + [['foo', 'bar', 'baz']], + [['one', 'two', 'three', 'four', 'five']], + ])('returns expected tags based on provided list', (tags) => { + setUp(tags); + + expect(screen.queryByText('No tags')).not.toBeInTheDocument(); + tags.forEach((tag) => expect(screen.getByText(tag)).toBeInTheDocument()); + }); +});