-
Notifications
You must be signed in to change notification settings - Fork 44
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 #2838 from glific/enhancements/adding-back-button
Added back button in forms
- Loading branch information
Showing
11 changed files
with
62 additions
and
32 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
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,36 @@ | ||
import { describe } from 'vitest'; | ||
import { Heading } from './Heading'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router'; | ||
|
||
const wrapper = ( | ||
<MemoryRouter> | ||
<Heading backLink={'/back-link'} formTitle={'Heading Title'} /> | ||
</MemoryRouter> | ||
); | ||
|
||
const mockedUsedNavigate = vi.fn(); | ||
vi.mock('react-router-dom', async () => ({ | ||
...(await vi.importActual('react-router-dom')), | ||
useNavigate: () => mockedUsedNavigate, | ||
})); | ||
|
||
describe('Heading', () => { | ||
test('it should have Heading Title as heading', async () => { | ||
const { getByText } = render(wrapper); | ||
|
||
await waitFor(() => { | ||
expect(getByText('Heading Title')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
test('it should navigate to the back link', async () => { | ||
const { getByTestId } = render(wrapper); | ||
|
||
fireEvent.click(getByTestId('back-button')); | ||
|
||
await waitFor(() => { | ||
expect(mockedUsedNavigate).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
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
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
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