-
Notifications
You must be signed in to change notification settings - Fork 77
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 #404 from bartoval/refactor_topology_components
refactor(Topology): ♻️ Abstract topology toolbar
- Loading branch information
Showing
7 changed files
with
372 additions
and
454 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,33 @@ | ||
import { createRef } from 'react'; | ||
|
||
import { render, waitFor } from '@testing-library/react'; | ||
import eventUser from '@testing-library/user-event'; | ||
|
||
import AlertToast, { ToastExposeMethods } from '../components/TopologyToasts'; | ||
|
||
describe('AlertToast', () => { | ||
it('should add a new alert when addMessage is called', async () => { | ||
const toastRef = createRef<ToastExposeMethods>(); | ||
const { findByText } = render(<AlertToast ref={toastRef} />); | ||
|
||
const addMessage = toastRef.current?.addMessage; | ||
expect(addMessage).toBeDefined(); | ||
|
||
addMessage!('This is a toast message!'); | ||
expect(await findByText('This is a toast message!')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should remove an alert when the close button is clicked', async () => { | ||
const toastRef = createRef<ToastExposeMethods>(); | ||
const { getByTestId } = render(<AlertToast ref={toastRef} timeout={false} />); | ||
|
||
const addMessage = toastRef.current?.addMessage; | ||
expect(addMessage).toBeDefined(); | ||
|
||
addMessage!('This is a toast message!'); | ||
const toast = await waitFor(() => getByTestId(`sk-toast-0`)); | ||
|
||
await eventUser.click(toast.querySelector('button') as HTMLButtonElement); | ||
expect(toast).not.toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.