-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic component test for ImportHistoryPage
- Loading branch information
Showing
4 changed files
with
82 additions
and
57 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
spec/javascript/components/import/ImportHIstoryPage.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,55 @@ | ||
import React from 'react' | ||
import { render, screen, waitFor } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import { http, HttpResponse } from 'msw' | ||
import { setupServer } from 'msw/node' | ||
import { expect, test, beforeAll, afterEach, afterAll } from 'vitest' | ||
|
||
import store from 'stores/store' | ||
import { accountsMock, accountTypesMock } from 'mocks/accountMocks' | ||
import { bankStatementsMock } from 'mocks/bankStatementMocks' | ||
import ImportHistoryPage from 'components/import/ImportHistoryPage' | ||
|
||
const handlers = [ | ||
http.get('/api/account_types', async () => { | ||
return HttpResponse.json(accountTypesMock) | ||
}), | ||
http.get('/api/accounts', async () => { | ||
return HttpResponse.json(accountsMock) | ||
}), | ||
http.get('/api/accounts/1/bank_statements', async () => { | ||
return HttpResponse.json(bankStatementsMock) | ||
}), | ||
] | ||
const server = setupServer(...handlers) | ||
|
||
beforeAll(() => server.listen()) | ||
afterEach(() => server.resetHandlers()) | ||
afterAll(() => server.close()) | ||
|
||
test('renders a list of accounts', async () => { | ||
render( | ||
<Provider store={store}> | ||
<ImportHistoryPage /> | ||
</Provider>, | ||
) | ||
|
||
// page header | ||
const pageTitle = screen.getByRole('heading', { level: 1 }) | ||
expect(pageTitle.textContent).toEqual('import history') | ||
|
||
await waitFor(() => { | ||
// delete button for each row | ||
expect(screen.getAllByText('Delete').length).toEqual(2) | ||
|
||
// bank statement 1 | ||
expect(screen.getByText('19-Oct-2001')).toBeDefined() | ||
expect(screen.getByText('one.ofx')).toBeDefined() | ||
expect(screen.getByText('6')).toBeDefined() | ||
|
||
// bank statement 2 | ||
expect(screen.getByText('20-Oct-2001')).toBeDefined() | ||
expect(screen.getByText('two.ofx')).toBeDefined() | ||
expect(screen.getByText('8')).toBeDefined() | ||
}) | ||
}) |
56 changes: 0 additions & 56 deletions
56
spec/javascript/components/import/ImportHistoryPage.test.js
This file was deleted.
Oops, something went wrong.
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