forked from reactstrap/reactstrap
/
Badge.spec.js
47 lines (33 loc) · 1.25 KB
/
Badge.spec.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
44
45
46
47
import React from 'react';
import { shallow } from 'enzyme';
import { Badge } from '../';
describe('Badge', () => {
it('should render a span by default', () => {
const wrapper = shallow(<Badge>Yo!</Badge>);
expect(wrapper.type()).toBe('span');
});
it('should render an anchor when when href is provided', () => {
const wrapper = shallow(<Badge href="#">Yo!</Badge>);
expect(wrapper.type()).toBe('a');
});
it('should render a custom tag when provided', () => {
const wrapper = shallow(<Badge tag="main">Yo!</Badge>);
expect(wrapper.type()).toBe('main');
});
it('should render children', () => {
const wrapper = shallow(<Badge>Yo!</Badge>);
expect(wrapper.text()).toBe('Yo!');
});
it('should render badges with secondary color', () => {
const wrapper = shallow(<Badge>Default Badge</Badge>);
expect(wrapper.hasClass('bg-secondary')).toBe(true);
});
it('should render Badges with other colors', () => {
const wrapper = shallow(<Badge color="danger">Danger Badge</Badge>);
expect(wrapper.hasClass('bg-danger')).toBe(true);
});
it('should render Badges as pills', () => {
const wrapper = shallow(<Badge pill>Pill Badge</Badge>);
expect(wrapper.hasClass('rounded-pill')).toBe(true);
});
});