-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathMessageStrip.test.js
43 lines (34 loc) · 1.59 KB
/
MessageStrip.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import MessageStrip from './MessageStrip';
import { mount } from 'enzyme';
import React from 'react';
describe('<MessageStrip />', () => {
describe('Prop spreading', () => {
test('should allow props to be spread to the MessageStrip component', () => {
const element = mount(<MessageStrip data-sample='Sample' />);
expect(
element.find('div').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
test('should allow props to be spread to the MessageStrip component\'s button element when dismissible', () => {
const element = mount(<MessageStrip buttonProps={{ 'data-sample': 'Sample' }} dismissible />);
expect(
element.find('button').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
test('should allow props to be spread to the MessageStrip component\'s a element when link provided', () => {
const element = mount(<MessageStrip link='#' linkProps={{ 'data-sample': 'Sample' }} />);
expect(
element.find('a').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});
describe('onClick handler', () => {
test('should dispatch the onClick callback with the event', () => {
let f = jest.fn();
const element = mount(<MessageStrip data-sample='Sample' dismissible
onCloseClicked={f} />);
element.find('button').simulate('click');
expect(f).toHaveBeenCalledTimes(1);
});
});
});