From 8d986b7ff42d34c54ab135e51e0b207d254be67f Mon Sep 17 00:00:00 2001 From: GuangbinMa Date: Thu, 11 Jan 2024 18:13:22 +0800 Subject: [PATCH] ADM-699: [frontend] test: prompt test coverage for ReportCard component --- .../Common/ReportGrid/ReportCard.test.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/__tests__/src/components/Common/ReportGrid/ReportCard.test.tsx b/frontend/__tests__/src/components/Common/ReportGrid/ReportCard.test.tsx index a4a13cd6aa..3b22a9578d 100644 --- a/frontend/__tests__/src/components/Common/ReportGrid/ReportCard.test.tsx +++ b/frontend/__tests__/src/components/Common/ReportGrid/ReportCard.test.tsx @@ -1,8 +1,13 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { ReportCard } from '@src/components/Common/ReportGrid/ReportCard'; +import clearAllMocks = jest.clearAllMocks; describe('Report Card', () => { + afterEach(() => { + clearAllMocks(); + }); + it('should not show exceeding items', () => { const items = [ { @@ -25,4 +30,14 @@ describe('Report Card', () => { expect(screen.getByText('2.00')).toBeInTheDocument(); expect(screen.queryByText('3.00')).not.toBeInTheDocument(); }); + + it('should show error message when errorMessage is not empty', () => { + const errorMessage = 'Data loading failed'; + + const { getByText, queryByText } = render( + + ); + + expect(screen.getByText('Data loading failed')).toBeInTheDocument(); + }); });