2019-09-06 09:29:18 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Badge from '.';
|
|
|
|
|
2019-09-06 09:46:03 +00:00
|
|
|
describe('<Badge />', () => {
|
2019-09-06 09:29:18 +00:00
|
|
|
it('renders without error', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-11-26 09:09:39 +00:00
|
|
|
|
|
|
|
it('displays number', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge number={10} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('number')).toBe(10);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('call onClick()', () => {
|
|
|
|
const onClick = jest.fn();
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge onClick={onClick} />
|
|
|
|
);
|
|
|
|
|
|
|
|
wrapper.simulate('click');
|
|
|
|
|
|
|
|
expect(onClick).toBeCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('call onClick() without wrapper', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge />
|
|
|
|
);
|
|
|
|
|
|
|
|
wrapper.simulate('click');
|
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('accepts id', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge id="testId" />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('id')).toEqual('testId');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('accepts className', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge className="test" />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('className')).toEqual('test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('accepts style', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Badge style={{ color: 'red' }} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty('color', 'red');
|
|
|
|
});
|
2019-09-06 09:29:18 +00:00
|
|
|
});
|