docbrown/app/javascript/Snackbar/__tests__/SnackbarItem.test.jsx
Nick Taylor d3171fb3c8
Created Snackbar components (#7415)
Created the Snackbar components.
2020-04-23 08:27:50 -04:00

36 lines
887 B
JavaScript

import { h } from 'preact';
import render from 'preact-render-to-json';
import { SnackbarItem } from '..';
describe('<SnackbarItem />', () => {
it('should render with just a message', () => {
const tree = render(<SnackbarItem message="File uploaded successfully" />);
expect(tree).toMatchSnapshot();
});
it('should render with one action', () => {
const tree = render(
<SnackbarItem
message="Changes saved"
actions={[{ text: 'Undo', handler: jest.fn() }]}
/>,
);
expect(tree).toMatchSnapshot();
});
it('should render with multiple actions', () => {
const tree = render(
<SnackbarItem
message="Unable to save file"
actions={[
{ text: 'Retry', handler: jest.fn() },
{ text: 'Abort', handler: jest.fn() },
]}
/>,
);
expect(tree).toMatchSnapshot();
});
});