From 2f90a34684b849f5e2297f82faf894092f2c0c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cavaleiro?= Date: Mon, 9 Oct 2023 10:20:21 +0100 Subject: [PATCH 1/3] feat(headline): [DSM-834] add tests --- malty/atoms/Headline/Headline.test.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/malty/atoms/Headline/Headline.test.tsx b/malty/atoms/Headline/Headline.test.tsx index 620152fc8..616798443 100644 --- a/malty/atoms/Headline/Headline.test.tsx +++ b/malty/atoms/Headline/Headline.test.tsx @@ -4,10 +4,19 @@ import React from 'react'; import { Headline } from './Headline'; const text = 'this is a headline'; +const testId = 'headline'; + describe('Headline component', () => { it('should render with the correct text', () => { - render({text}); + render({text} ); + const rendered = screen.getByText(text); + expect(rendered).toBeInTheDocument(); + }); + + it('should have the assigned data test id', () => { + render({text} ); const rendered = screen.getByText(text); expect(rendered).toBeInTheDocument(); + expect(rendered).toHaveAttribute('data-testid', testId); }); }); From 538ac6731a9fadc6fe44aa4c1831aca73dacd192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cavaleiro?= Date: Wed, 11 Oct 2023 15:45:17 +0100 Subject: [PATCH 2/3] test id assertion update --- malty/atoms/Headline/Headline.test.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/malty/atoms/Headline/Headline.test.tsx b/malty/atoms/Headline/Headline.test.tsx index 616798443..282eb5bbb 100644 --- a/malty/atoms/Headline/Headline.test.tsx +++ b/malty/atoms/Headline/Headline.test.tsx @@ -9,14 +9,17 @@ const testId = 'headline'; describe('Headline component', () => { it('should render with the correct text', () => { render({text} ); + const rendered = screen.getByText(text); + expect(rendered).toBeInTheDocument(); }); it('should have the assigned data test id', () => { render({text} ); - const rendered = screen.getByText(text); + + const rendered = screen.getByTestId(testId); + expect(rendered).toBeInTheDocument(); - expect(rendered).toHaveAttribute('data-testid', testId); }); }); From 23513410f1896f8ff667768a9c17c816e2e0b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cavaleiro?= Date: Wed, 11 Oct 2023 16:08:15 +0100 Subject: [PATCH 3/3] space refactoring --- malty/atoms/Headline/Headline.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/malty/atoms/Headline/Headline.test.tsx b/malty/atoms/Headline/Headline.test.tsx index 282eb5bbb..2a64a85c1 100644 --- a/malty/atoms/Headline/Headline.test.tsx +++ b/malty/atoms/Headline/Headline.test.tsx @@ -8,7 +8,7 @@ const testId = 'headline'; describe('Headline component', () => { it('should render with the correct text', () => { - render({text} ); + render({text}); const rendered = screen.getByText(text); @@ -16,7 +16,7 @@ describe('Headline component', () => { }); it('should have the assigned data test id', () => { - render({text} ); + render({text}); const rendered = screen.getByTestId(testId);