Skip to content

Commit 00242e1

Browse files
cloned group tests for scatter plot
not that I had any doubts here, just affirming for #1239
1 parent e12e97b commit 00242e1

File tree

1 file changed

+59
-35
lines changed

1 file changed

+59
-35
lines changed

spec/scatter-plot-spec.js

+59-35
Original file line numberDiff line numberDiff line change
@@ -120,47 +120,71 @@ describe('dc.scatterPlot', function () {
120120
});
121121
});
122122

123-
describe('filtering another dimension', function () {
124-
var otherDimension;
123+
function filteringAnotherDimension () {
124+
describe('filtering another dimension', function () {
125+
var otherDimension;
125126

126-
beforeEach(function () {
127-
otherDimension = data.dimension(function (d) { return [+d.value, +d.nvalue]; });
128-
var ff = dc.filters.RangedTwoDimensionalFilter([[22, -3], [44, 2]]).isFiltered;
129-
otherDimension.filterFunction(ff);
130-
chart.redraw();
131-
});
127+
beforeEach(function () {
128+
otherDimension = data.dimension(function (d) { return [+d.value, +d.nvalue]; });
129+
var ff = dc.filters.RangedTwoDimensionalFilter([[22, -3], [44, 2]]).isFiltered;
130+
otherDimension.filterFunction(ff);
131+
chart.redraw();
132+
});
132133

133-
it('should show the included points', function () {
134-
var shownPoints = symbolsOfRadius(10); // test symbolSize
135-
expect(shownPoints.length).toBe(2);
136-
expect(shownPoints[0].key).toEqual([22, -2]);
137-
expect(shownPoints[1].key).toEqual([33, 1]);
138-
});
139-
it('should hide the excluded points', function () {
140-
var emptyPoints = symbolsOfRadius(4); // test emptySize
141-
expect(emptyPoints.length).toBe(7);
142-
});
143-
it('should use emptyOpacity for excluded points', function () {
144-
var translucentPoints = symbolsMatching(function () {
145-
return +d3.select(this).attr('opacity') === 0.5; // emptyOpacity
134+
it('should show the included points', function () {
135+
var shownPoints = symbolsOfRadius(10); // test symbolSize
136+
expect(shownPoints.length).toBe(2);
137+
expect(shownPoints[0].key).toEqual([22, -2]);
138+
expect(shownPoints[1].key).toEqual([33, 1]);
146139
});
147-
expect(translucentPoints.length).toBe(7);
148-
});
149-
it('should use emptyColor for excluded points', function () {
150-
var chartreusePoints = symbolsMatching(function () { // don't try this at home
151-
return /#DFFF00/i.test(d3.select(this).attr('fill')); // emptyColor
140+
it('should hide the excluded points', function () {
141+
var emptyPoints = symbolsOfRadius(4); // test emptySize
142+
expect(emptyPoints.length).toBe(7);
152143
});
153-
expect(chartreusePoints.length).toBe(7);
154-
});
155-
it('should update the titles', function () {
156-
var titles = chart.selectAll('path.symbol title');
157-
var expected = ['22,-2: 1','22,10: 0','33,1: 2','44,-3: 0','44,-4: 0',
158-
'44,2: 0','55,-3: 0','55,-5: 0','66,-4: 0'];
159-
expect(titles.size()).toBe(expected.length);
160-
titles.each(function (d) {
161-
expect(this.textContent).toBe(expected.shift());
144+
it('should use emptyOpacity for excluded points', function () {
145+
var translucentPoints = symbolsMatching(function () {
146+
return +d3.select(this).attr('opacity') === 0.5; // emptyOpacity
147+
});
148+
expect(translucentPoints.length).toBe(7);
149+
});
150+
it('should use emptyColor for excluded points', function () {
151+
var chartreusePoints = symbolsMatching(function () { // don't try this at home
152+
return /#DFFF00/i.test(d3.select(this).attr('fill')); // emptyColor
153+
});
154+
expect(chartreusePoints.length).toBe(7);
162155
});
156+
it('should update the titles', function () {
157+
var titles = chart.selectAll('path.symbol title');
158+
var expected = ['22,-2: 1','22,10: 0','33,1: 2','44,-3: 0','44,-4: 0',
159+
'44,2: 0','55,-3: 0','55,-5: 0','66,-4: 0'];
160+
expect(titles.size()).toBe(expected.length);
161+
titles.each(function (d) {
162+
expect(this.textContent).toBe(expected.shift());
163+
});
164+
});
165+
});
166+
}
167+
filteringAnotherDimension();
168+
169+
function cloneGroup (group) {
170+
return {
171+
all: function () {
172+
return group.all().map(function (kv) {
173+
return {
174+
key: kv.key.slice(0),
175+
value: kv.value
176+
};
177+
});
178+
}
179+
};
180+
}
181+
describe('with cloned data', function () {
182+
beforeEach(function () {
183+
chart.group(cloneGroup(group))
184+
.render();
163185
});
186+
187+
filteringAnotherDimension();
164188
});
165189

166190
describe('brushing', function () {

0 commit comments

Comments
 (0)