-
Notifications
You must be signed in to change notification settings - Fork 975
/
index.spec.js
45 lines (40 loc) · 1.82 KB
/
index.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
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import theme from '../theme.css';
import Button, { Button as RawButton } from '../Button';
const getRenderedClassName = (tree, Component) => {
const rendered = TestUtils.findRenderedComponentWithType(tree, Component);
return ReactDOM.findDOMNode(rendered).getAttribute('class');
};
describe('Button', function () {
describe('#render', function () {
it('uses flat and neutral styles by default', function () {
const tree = TestUtils.renderIntoDocument(<Button theme={theme} />);
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
expect(className).toContain(theme.neutral);
});
it('renders accent button with accent style', function () {
const tree = TestUtils.renderIntoDocument(<Button accent theme={theme} />);
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
expect(className).toContain(theme.accent);
});
it('renders mini button with mini style', function () {
const tree = TestUtils.renderIntoDocument(<Button floating mini theme={theme} />);
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.floating);
expect(className).toContain(theme.neutral);
expect(className).toContain(theme.mini);
});
it('renders mini accented button with both styles', function () {
const tree = TestUtils.renderIntoDocument(<Button accent mini theme={theme} />);
const className = getRenderedClassName(tree, RawButton);
expect(className).toContain(theme.flat);
expect(className).toContain(theme.accent);
expect(className).toContain(theme.mini);
});
});
});