From 2d2a3b4ef58ca2b4461eddff3db3df8c10343878 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Fri, 10 Nov 2023 14:09:26 -0600 Subject: [PATCH] Add range tests --- .../AppointmentResults.test.tsx | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/components/Coaching/CoachingDetail/AppointmentResults/AppointmentResults.test.tsx b/src/components/Coaching/CoachingDetail/AppointmentResults/AppointmentResults.test.tsx index 32034eec7..d33a0fe27 100644 --- a/src/components/Coaching/CoachingDetail/AppointmentResults/AppointmentResults.test.tsx +++ b/src/components/Coaching/CoachingDetail/AppointmentResults/AppointmentResults.test.tsx @@ -1,4 +1,4 @@ -import { render } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; import { CoachingPeriodEnum } from '../CoachingDetail'; import { AppointmentResults } from './AppointmentResults'; @@ -40,6 +40,8 @@ const mocks = { }, }; +const mutationSpy = jest.fn(); + describe('AppointmentResults', () => { it('renders the table data', async () => { const { findByRole, getAllByRole } = render( @@ -126,4 +128,40 @@ describe('AppointmentResults', () => { expect(specialIncreaseRow.children[3]).toHaveTextContent('$1,000'); expect(specialIncreaseRow.children[4]).toHaveTextContent('$630'); }); + + it('loads data for the weekly period', async () => { + render( + + + , + ); + + await waitFor(() => + expect(mutationSpy.mock.calls[0][0].operation.variables).toMatchObject({ + range: '4w', + }), + ); + }); + + it('loads data for the monthly period', async () => { + render( + + + , + ); + + await waitFor(() => + expect(mutationSpy.mock.calls[0][0].operation.variables).toMatchObject({ + range: '4m', + }), + ); + }); });