regexper-static/src/components/Message/test.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

jest.mock('react-feather/dist/icons/info', () =>
require('__mocks__/component-mock')('react-feather/dist/icons/info'));
jest.mock('react-feather/dist/icons/alert-octagon', () =>
require('__mocks__/component-mock')(
'react-feather/dist/icons/alert-octagon'
));
jest.mock('react-feather/dist/icons/alert-triangle', () =>
require('__mocks__/component-mock')(
'react-feather/dist/icons/alert-triangle'
));
jest.mock('react-feather/dist/icons/x-square', () =>
require('__mocks__/component-mock')('react-feather/dist/icons/x-square'));
2019-01-04 23:38:49 +00:00
import React from 'react';
import { render } from 'react-testing-library';
2019-01-04 23:38:49 +00:00
import Message from 'components/Message';
describe('Message', () => {
test('rendering', () => {
const { asFragment } = render(
2019-01-04 23:38:49 +00:00
<Message heading="Testing">
<p>Message content</p>
</Message>
);
expect(asFragment()).toMatchSnapshot();
2019-01-04 23:38:49 +00:00
});
test('rendering with icon', () => {
const Icon = () => 'Sample icon SVG';
const { asFragment } = render(
2019-01-04 23:38:49 +00:00
<Message heading="Testing" icon={ Icon }>
<p>Message content</p>
</Message>
);
expect(asFragment()).toMatchSnapshot();
2019-01-04 23:38:49 +00:00
});
test('rendering with type', () => {
const { asFragment } = render(
2019-01-04 23:38:49 +00:00
<Message heading="Testing" type="error">
<p>Message content</p>
</Message>
);
expect(asFragment()).toMatchSnapshot();
2019-01-04 23:38:49 +00:00
});
test('rendering with a close button', () => {
const { asFragment } = render(
<Message heading="Testing" onClose={ jest.fn() }>
<p>Message content</p>
</Message>
);
expect(asFragment()).toMatchSnapshot();
});
2019-01-04 23:38:49 +00:00
});