-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplot.spec.js
86 lines (76 loc) · 2.04 KB
/
plot.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
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
78
79
80
81
82
83
84
85
86
import { assert } from 'chai';
import Plot from '../src/plot.jsx';
import React from 'react/addons';
import ReactDOM from 'react-dom';
const ReactTestUtils = React.addons.TestUtils;
class SinglePlotWrapper extends React.Component {
render() {
return (
<Plot
className='plot1'
fn={x => x * x}
height={300}
width={300}
thickness={4}
/>
);
}
}
class MultiplePlotWrapper extends React.Component {
render() {
return (
<div>
<Plot
className='plot1'
fn={x => x * x}
height={300}
width={300}
thickness={4}
/>
<Plot
className='plot2'
fn={x => x * x}
height={300}
width={300}
thickness={4}
/>
</div>
);
}
}
describe('Plot', () => {
let spw;
describe('Single Plot renderer', () => {
beforeEach(() => {
spw = ReactTestUtils.renderIntoDocument(<SinglePlotWrapper/>);
});
it('renders a single plot', () => {
const plots = ReactTestUtils.scryRenderedDOMComponentsWithClass(spw, "plot");
assert.isDefined(plots);
assert.equal(plots.length, 1);
});
it('(the plot) is a DIV', () => {
const plotNode =
ReactDOM.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithClass(spw, "plot"));
assert.isDefined(plotNode);
assert.equal(plotNode.tagName, 'DIV');
});
});
describe('Multiple Plot renderer', () => {
beforeEach(() => {
spw = ReactTestUtils.renderIntoDocument(<MultiplePlotWrapper/>);
});
it('renders two plots', () => {
const plots = ReactTestUtils.scryRenderedDOMComponentsWithClass(spw, "plot");
assert.isDefined(plots);
assert.equal(plots.length, 2);
});
it('(each plot) is a DIV', () => {
const plots = ReactTestUtils.scryRenderedDOMComponentsWithClass(spw, "plot");
plots.forEach(plot => {
const plotNode = ReactDOM.findDOMNode(plot);
assert.equal(plotNode.tagName, 'DIV');
});
});
});
});