-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(NavigationBreadcrumbs): allow executing onNavigate when pressing…
… a link (#1233)
- Loading branch information
1 parent
3f99e4a
commit ec7ed8b
Showing
2 changed files
with
36 additions
and
1 deletion.
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,33 @@ | ||
import * as React from 'react'; | ||
import {render, screen} from '@testing-library/react'; | ||
import ThemeContextProvider from '../theme-context-provider'; | ||
import {makeTheme} from './test-utils'; | ||
import NavigationBreadcrumbs from '../navigation-breadcrumbs'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
test('Breadcrumbs onNavigate is called when pressing a link', async () => { | ||
const navigateSpy = jest.fn(); | ||
|
||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<NavigationBreadcrumbs | ||
title="Title" | ||
breadcrumbs={[ | ||
{title: 'breadcrumb 1', url: '#', onNavigate: () => navigateSpy('breadcrumb 1')}, | ||
{title: 'breadcrumb 2', url: '#', onNavigate: () => navigateSpy('breadcrumb 2')}, | ||
]} | ||
/> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const firstLink = await screen.findByRole('link', {name: 'breadcrumb 1'}); | ||
const secondLink = await screen.findByRole('link', {name: 'breadcrumb 2'}); | ||
|
||
await userEvent.click(firstLink); | ||
expect(navigateSpy).toHaveBeenLastCalledWith('breadcrumb 1'); | ||
expect(navigateSpy).toHaveBeenCalledTimes(1); | ||
|
||
await userEvent.click(secondLink); | ||
expect(navigateSpy).toHaveBeenLastCalledWith('breadcrumb 2'); | ||
expect(navigateSpy).toHaveBeenCalledTimes(2); | ||
}); |
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
ec7ed8b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for mistica-web ready!
✅ Preview
https://mistica-4gbvasio4-flows-projects-65bb050e.vercel.app
Built with commit ec7ed8b.
This pull request is being automatically deployed with vercel-action