Skip to content

Commit

Permalink
Add Jasmine specs for Row chart elasticX
Browse files Browse the repository at this point in the history
  • Loading branch information
sebgrohn committed Jun 20, 2016
1 parent 1f90053 commit 93df36f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions spec/row-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('dc.rowChart', function () {
});
});

function itShouldBehaveLikeARowChartWithGroup (groupHolder, N) {
function itShouldBehaveLikeARowChartWithGroup (groupHolder, N, xAxisTicks) {
describe('for ' + groupHolder.groupType + ' data', function () {
beforeEach(function () {
chart.group(groupHolder.group);
Expand Down Expand Up @@ -352,11 +352,30 @@ describe('dc.rowChart', function () {
});
});
});

if (xAxisTicks) {
describe('with elasticX', function () {
beforeEach(function () {
chart.elasticX(true)
.xAxis().ticks(3);

chart.render();
});

it('should generate x axis domain dynamically', function () {
var nthText = function (n) { return d3.select(chart.selectAll('g.axis .tick text')[0][n]); };

for (let i = 0; i < xAxisTicks.length; i++) {
expect(nthText(i).text()).toBe(xAxisTicks[i]);
}
});
});
}
});
}

itShouldBehaveLikeARowChartWithGroup(positiveGroupHolder, 5);
itShouldBehaveLikeARowChartWithGroup(negativeGroupHolder, 5);
itShouldBehaveLikeARowChartWithGroup(mixedGroupHolder, 5);
itShouldBehaveLikeARowChartWithGroup(positiveGroupHolder, 5, ['0', '5', '10']);
itShouldBehaveLikeARowChartWithGroup(negativeGroupHolder, 5, ['-10', '-5', '0']);
itShouldBehaveLikeARowChartWithGroup(mixedGroupHolder, 5, ['-5', '0', '5']);
itShouldBehaveLikeARowChartWithGroup(largerGroupHolder, 7);
});

0 comments on commit 93df36f

Please sign in to comment.