forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.spec.js
More file actions
56 lines (44 loc) · 1.89 KB
/
Copy pathCard.spec.js
File metadata and controls
56 lines (44 loc) · 1.89 KB
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
48
49
50
51
52
53
54
55
56
import React from 'react';
import { shallow } from 'enzyme';
import { Card } from '../';
describe('Card', () => {
it('should render with "card" class', () => {
const wrapper = shallow(<Card>Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('card')).toBe(true);
});
it('should render with "modal-header" class', () => {
const wrapper = shallow(<Card inverse block color="primary">Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('card')).toBe(true);
expect(wrapper.hasClass('card-body')).toBe(true);
expect(wrapper.hasClass('bg-primary')).toBe(true);
expect(wrapper.hasClass('text-white')).toBe(true);
});
it('should render with "outline" class when a color is provided', () => {
const wrapper = shallow(<Card outline block color="primary">Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('card')).toBe(true);
expect(wrapper.hasClass('card-body')).toBe(true);
expect(wrapper.hasClass('border-primary')).toBe(true);
});
it('should not render with "outline" class when a color is not provided (no default)', () => {
const wrapper = shallow(<Card outline block>Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('card')).toBe(true);
expect(wrapper.hasClass('card-body')).toBe(true);
expect(wrapper.html()).not.toContain('border');
});
it('should render additional classes', () => {
const wrapper = shallow(<Card className="other">Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('other')).toBe(true);
expect(wrapper.hasClass('card')).toBe(true);
});
it('should render custom tag', () => {
const wrapper = shallow(<Card tag="main">Yo!</Card>);
expect(wrapper.text()).toBe('Yo!');
expect(wrapper.hasClass('card')).toBe(true);
expect(wrapper.find('main').length).toBe(1);
});
});