1 | import Color from 'color';
|
2 | import ReactDOM from 'react-dom';
|
3 | import TestUtils from 'react-addons-test-utils';
|
4 |
|
5 | export function getRenderOutput(element) {
|
6 | const renderer = TestUtils.createRenderer();
|
7 | renderer.render(element);
|
8 | return renderer.getRenderOutput();
|
9 | }
|
10 |
|
11 | export function getElement(output, tagName) {
|
12 | return ReactDOM.findDOMNode(
|
13 | TestUtils.findRenderedDOMComponentWithTag(output, tagName),
|
14 | );
|
15 | }
|
16 |
|
17 | function cleanCSS(css) {
|
18 | return css.replace(/\s*\n\s*/g, '').replace(/\s*([{};:,])\s*/g, '$1');
|
19 | }
|
20 |
|
21 | export function expectCSS(styleElement, css) {
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | expect(cleanCSS(styleElement.innerText)).to.equal(cleanCSS(css));
|
27 | }
|
28 |
|
29 | export function expectColor(actual, expected) {
|
30 | expect(Color(actual).hex()).to.equal(Color(expected).hex());
|
31 | }
|