forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBadgeSpec.js
More file actions
77 lines (68 loc) · 2.13 KB
/
BadgeSpec.js
File metadata and controls
77 lines (68 loc) · 2.13 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ReactDOM from 'react-dom';
import Badge from '../src/Badge';
describe('<Badge>', () => {
it('Should output a badge with content', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge>
<strong>Content</strong>
</Badge>
);
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong'));
});
it('Should have a badge class', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge>
Content
</Badge>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbadge\b/));
});
it('Should have a badge using a number', () => {
let count = 42;
let instance = ReactTestUtils.renderIntoDocument(
<Badge>
{count}
</Badge>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbadge\b/));
});
it('Should have a badge using a a mix of content', () => {
let count = 42;
let instance = ReactTestUtils.renderIntoDocument(
<Badge>
£{count}
</Badge>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bbadge\b/));
});
it('Should have a badge class pulled right', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge pullRight>
Content
</Badge>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bpull-right\b/));
});
describe('Hides when empty', () => {
it('should hide with no children', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge />
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bhidden\b/));
});
it('should hide with empty string', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge>{''}</Badge>
);
assert.ok(ReactDOM.findDOMNode(instance).className.match(/\bhidden\b/));
});
it('should not hide 0', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Badge>{0}</Badge>
);
assert.notOk(ReactDOM.findDOMNode(instance).className.match(/\bhidden\b/));
});
});
});