Skip to content

Commit

Permalink
Add range tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Nov 10, 2023
1 parent d0617e0 commit 2d2a3b4
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -40,6 +40,8 @@ const mocks = {
},
};

const mutationSpy = jest.fn();

describe('AppointmentResults', () => {
it('renders the table data', async () => {
const { findByRole, getAllByRole } = render(
Expand Down Expand Up @@ -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(
<GqlMockedProvider onCall={mutationSpy}>
<AppointmentResults
accountListId="account-list-1"
period={CoachingPeriodEnum.Weekly}
currency="USD"
/>
</GqlMockedProvider>,
);

await waitFor(() =>
expect(mutationSpy.mock.calls[0][0].operation.variables).toMatchObject({
range: '4w',
}),
);
});

it('loads data for the monthly period', async () => {
render(
<GqlMockedProvider onCall={mutationSpy}>
<AppointmentResults
accountListId="account-list-1"
period={CoachingPeriodEnum.Monthly}
currency="USD"
/>
</GqlMockedProvider>,
);

await waitFor(() =>
expect(mutationSpy.mock.calls[0][0].operation.variables).toMatchObject({
range: '4m',
}),
);
});
});

0 comments on commit 2d2a3b4

Please sign in to comment.