/
BadgeSpec.jsx
51 lines (45 loc) · 1.44 KB
/
BadgeSpec.jsx
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
/*global describe, beforeEach, afterEach, it, assert */
var React = require('react');
var ReactTestUtils = require('react/lib/ReactTestUtils');
var Badge = require('../lib/Badge');
describe('Badge', function () {
it('Should output a badge with content', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Badge>
<strong>Content</strong>
</Badge>
);
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong'));
});
it('Should have a badge class', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Badge>
Content
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
});
it('Should have a badge using a number', function () {
var count = 42;
var instance = ReactTestUtils.renderIntoDocument(
<Badge>
{count}
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
});
it('Should have a badge class pulled right', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Badge pullRight>
Content
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bpull-right\b/));
});
it('Should not have a badge class when empty', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Badge></Badge>
);
assert.notOk(instance.getDOMNode().className.match(/\bbadge\b/));
});
});