forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassert_style.js
33 lines (25 loc) · 957 Bytes
/
assert_style.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
'use strict';
var d3 = require('d3');
module.exports = function assertStyle(dims, color, opacity) {
var N = dims.reduce(function(a, b) {
return a + b;
});
var traces = d3.selectAll('.trace');
expect(traces.size())
.toEqual(dims.length, 'to have correct number of traces');
expect(d3.selectAll('.point').size())
.toEqual(N, 'to have correct total number of points');
traces.each(function(_, i) {
var trace = d3.select(this);
var points = trace.selectAll('.point');
expect(points.size())
.toEqual(dims[i], 'to have correct number of pts in trace ' + i);
points.each(function() {
var point = d3.select(this);
expect(point.style('fill'))
.toEqual(color[i], 'to have correct pt color');
expect(+point.style('opacity'))
.toEqual(opacity[i], 'to have correct pt opacity');
});
});
};