-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ToastNotification): add dismissType with automated dismissing (#…
…1980) - add in new feature with default - add tests and snapshots
- Loading branch information
1 parent
e754588
commit 8545f14
Showing
5 changed files
with
65 additions
and
10 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 was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/components/ToastNotification/ToastNotification.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,26 @@ | ||
import { generateSnapshots } from '@chanzuckerberg/story-utils'; | ||
import { composeStories, type StoryFile } from '@storybook/testing-react'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
|
||
import React from 'react'; | ||
import * as stories from './ToastNotification.stories'; | ||
|
||
const { AutoDismiss } = composeStories(stories); | ||
|
||
const { AutoDismiss: skip, ...staticStories } = stories; | ||
|
||
describe('<ToastNotification /> (v2)', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
generateSnapshots(staticStories as StoryFile); | ||
|
||
it('triggers the onDissmiss after a delay', async () => { | ||
const consoleSpy = jest.spyOn(console, 'log').mockImplementation(); | ||
|
||
render(<AutoDismiss />); | ||
|
||
await waitFor(() => expect(consoleSpy).toHaveBeenCalledTimes(1)); | ||
}); | ||
}); |
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
File renamed without changes.