-
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.
Merge pull request #24 from JosephGasiorekUSDS/jgasiorek-connect-some…
…-screens Connect some ledger screens
- Loading branch information
Showing
4 changed files
with
114 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { afterEach, beforeEach, describe, expect, it, test } from 'vitest' | ||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import Page from './page' | ||
import { makeStore } from '@/lib/store' | ||
import { vi } from 'vitest' | ||
import { EnhancedStore } from '@reduxjs/toolkit' | ||
import mockRouter from 'next-router-mock' | ||
|
||
describe('SNAP Expense Screen', async () => { | ||
let store: EnhancedStore | ||
beforeEach(() => { | ||
vi.mock('next/navigation', () => require('next-router-mock')) | ||
mockRouter.push('/ledger/expense/snap') | ||
store = makeStore() | ||
render (<Provider store={store}><Page /></Provider>) | ||
}) | ||
afterEach(cleanup) | ||
|
||
it('shows header', () => { | ||
expect(screen.getByTestId('expense-snap-header')).toBeDefined() | ||
}) | ||
|
||
it('navigates to review screen if no is selected', async () => { | ||
fireEvent.click(screen.getByTestId("no_radio")) | ||
fireEvent.click(screen.getByTestId("continue-button")) | ||
|
||
await waitFor(() => { | ||
expect(mockRouter).toMatchObject({ | ||
asPath: "/ledger/review" | ||
}) | ||
}) | ||
}) | ||
|
||
it('navigates to ledger builder if yes is selected', async () => { | ||
fireEvent.click(screen.getByTestId("yes_radio")) | ||
fireEvent.click(screen.getByTestId("continue-button")) | ||
|
||
await waitFor(() => { | ||
expect(mockRouter).toMatchObject({ | ||
asPath: "/ledger/expense" | ||
}) | ||
}) | ||
}) | ||
}) |
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 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 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