/
AbstractAction-test.js
43 lines (35 loc) · 1.1 KB
/
AbstractAction-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
/* eslint-disable import/no-extraneous-dependencies */
/* global jest, describe, it, expect */
import React from 'react';
import AbstractAction from '../AbstractAction';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16/build/index';
Enzyme.configure({ adapter: new Adapter() });
describe('AbstractAction', () => {
const clickHandler = jest.fn();
let wrapper = null;
beforeEach(() => {
wrapper = mount(
<AbstractAction
onClick={clickHandler}
title="My abstract action"
disabled={false}
className="foo-bar"
toggle={false}
/>
);
});
it('renders a DropdownItem', () => {
expect(wrapper.find('DropdownItem').length).toBe(1);
});
it('includes the title text', () => {
expect(wrapper.text()).toContain('My abstract action');
});
it('delegates clicking to the provided handler', () => {
wrapper.find('button').simulate('click');
expect(clickHandler).toHaveBeenCalled();
});
it('adds provided extra classes', () => {
expect(wrapper.find('button').hasClass('foo-bar')).toBe(true);
});
});