-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the accountListId to the finish page URL
- Loading branch information
Showing
4 changed files
with
74 additions
and
150 deletions.
There are no files selected for viewing
File renamed without changes.
66 changes: 66 additions & 0 deletions
66
pages/accountLists/[accountListId]/setup/finish.page.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { render, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import TestRouter from '__tests__/util/TestRouter'; | ||
import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
import AccountPage from './finish.page'; | ||
|
||
jest.mock('src/lib/apollo/ssrClient'); | ||
|
||
const accountListId = 'account-list-1'; | ||
|
||
const push = jest.fn(); | ||
const router = { | ||
query: { accountListId }, | ||
isReady: true, | ||
push, | ||
}; | ||
|
||
const mutationSpy = jest.fn(); | ||
|
||
const TestComponent: React.FC = () => ( | ||
<TestRouter router={router}> | ||
<GqlMockedProvider onCall={mutationSpy}> | ||
<AccountPage /> | ||
</GqlMockedProvider> | ||
</TestRouter> | ||
); | ||
|
||
describe('Finish account page', () => { | ||
it('immediately sets setup position to finish', async () => { | ||
render(<TestComponent />); | ||
|
||
await waitFor(() => | ||
expect(mutationSpy).toHaveGraphqlOperation('UpdateSetupPosition', { | ||
setupPosition: 'finish', | ||
}), | ||
); | ||
}); | ||
|
||
it('yes button redirects to tools', async () => { | ||
const { getByRole } = render(<TestComponent />); | ||
|
||
userEvent.click(getByRole('button', { name: /Yes/ })); | ||
|
||
await waitFor(() => | ||
expect(mutationSpy).toHaveGraphqlOperation('UpdateSetupPosition', { | ||
setupPosition: '', | ||
}), | ||
); | ||
expect(push).toHaveBeenCalledWith( | ||
`/accountLists/${accountListId}/tools?setup=1`, | ||
); | ||
}); | ||
|
||
it('no button redirects to the dashboard', async () => { | ||
const { getByRole } = render(<TestComponent />); | ||
|
||
userEvent.click(getByRole('button', { name: /Nope/ })); | ||
|
||
await waitFor(() => | ||
expect(mutationSpy).toHaveGraphqlOperation('UpdateSetupPosition', { | ||
setupPosition: '', | ||
}), | ||
); | ||
expect(push).toHaveBeenCalledWith(`/accountLists/${accountListId}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.