Skip to content

Commit

Permalink
add tests for hovering external labels and paths
Browse files Browse the repository at this point in the history
for #1167
but wow! the test dynamically fails to compile due to dc.transition
returning a selection if duration===0
  • Loading branch information
gordonwoodhull committed Jul 28, 2016
1 parent ee53b10 commit 5ad6a2b
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions spec/pie-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ describe('dc.pieChart', function () {
beforeEach(function () {
chart = buildChart('pie-chart-external-labeling')
.externalLabels(10)
.drawPaths(true)
.render();
});
it('should place labels outside of pie offset by given radius', function () {
Expand Down Expand Up @@ -617,6 +618,43 @@ describe('dc.pieChart', function () {
expect(label.classed('external')).toBeFalsy();
});
});
it('hovering on label should highlight corresponding slice', function () {
chart.selectAll('#pie-chart-external-labeling text.pie-slice').each(function (d, i) {
var legendItem = d3.select(this);
legendItem.on('mouseover')(legendItem.datum(), i);

expect(chart.select('g.pie-slice._' + i).classed('highlight')).toBeTruthy();
legendItem.on('mouseout')(legendItem.datum());
});
});
it('unhovering label removes highlight from corresponding slice', function () {
chart.selectAll('#pie-chart-external-labeling text.pie-slice').each(function (d, i) {
var legendItem = d3.select(this);
legendItem.on('mouseover')(legendItem.datum(), i);
legendItem.on('mouseout')(legendItem.datum(), i);

expect(chart.select('.pie-slice._' + i).classed('highlight')).toBeFalsy();
});
});

it('hovering on path should highlight corresponding slice', function () {
chart.selectAll('#pie-chart-external-labeling polyline.pie-path').each(function (d, i) {
var legendItem = d3.select(this);
legendItem.on('mouseover')(legendItem.datum(), i);

expect(chart.select('g.pie-slice._' + i).classed('highlight')).toBeTruthy();
legendItem.on('mouseout')(legendItem.datum());
});
});
it('unhovering label removes highlight from corresponding slice', function () {
chart.selectAll('#pie-chart-external-labeling polyline.pie-path').each(function (d, i) {
var legendItem = d3.select(this);
legendItem.on('mouseover')(legendItem.datum(), i);
legendItem.on('mouseout')(legendItem.datum(), i);

expect(chart.select('.pie-slice._' + i).classed('highlight')).toBeFalsy();
});
});
});

describe('legends', function () {
Expand Down Expand Up @@ -647,7 +685,7 @@ describe('dc.pieChart', function () {
var legendItem = d3.select(this);
legendItem.on('mouseover')(legendItem.datum());

expect(chart.select('.pie-slice._' + i).classed('highlight')).toBeTruthy();
expect(chart.select('g.pie-slice._' + i).classed('highlight')).toBeTruthy();
legendItem.on('mouseout')(legendItem.datum());
});
});
Expand All @@ -657,7 +695,7 @@ describe('dc.pieChart', function () {
legendItem.on('mouseover')(legendItem.datum());
legendItem.on('mouseout')(legendItem.datum());

expect(chart.select('.pie-slice._' + i).classed('highlight')).toBeFalsy();
expect(chart.select('g.pie-slice._' + i).classed('highlight')).toBeFalsy();
});
});
it('clicking on items filters them', function () {
Expand Down

0 comments on commit 5ad6a2b

Please sign in to comment.