Skip to content

Commit

Permalink
Automated Prettier for specs
Browse files Browse the repository at this point in the history
  • Loading branch information
kum-deepak committed Mar 31, 2024
1 parent 83752a0 commit ee9dd26
Show file tree
Hide file tree
Showing 37 changed files with 2,365 additions and 1,419 deletions.
351 changes: 218 additions & 133 deletions spec/bar-chart-spec.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions spec/base-mixin-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,7 @@ describe('dc.baseMixin', () => {

describe('with viewbox enabled', () => {
beforeEach(() => {
chart
.useViewBoxResizing(true)
.resetSvg();
chart.useViewBoxResizing(true).resetSvg();
});

it('has useViewBoxResizing set', () => {
Expand Down
28 changes: 16 additions & 12 deletions spec/biggish-data-spec.js

Large diffs are not rendered by default.

47 changes: 23 additions & 24 deletions spec/box-plot-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ describe('dc.BoxPlot', () => {

dimension = data.dimension(d => d.countrycode);
group = dimension.group().reduce(
(p, v) => { p.push(+v.value); return p; },
(p, v) => { p.splice(p.indexOf(+v.value), 1); return p; },
(p, v) => {
p.push(+v.value);
return p;
},
(p, v) => {
p.splice(p.indexOf(+v.value), 1);
return p;
},
() => []
);

Expand All @@ -22,12 +28,12 @@ describe('dc.BoxPlot', () => {
.group(group)
.width(300)
.height(144)
.margins({top: 0, right: 0, bottom: 0, left: 0})
.margins({ top: 0, right: 0, bottom: 0, left: 0 })
.boxPadding(0)
.transitionDuration(0)
.transitionDelay(0)
.y(d3.scaleLinear().domain([0, 144]))
.ordinalColors(['#01','#02']);
.ordinalColors(['#01', '#02']);
});

describe('rendering the box plot', () => {
Expand Down Expand Up @@ -86,11 +92,7 @@ describe('dc.BoxPlot', () => {

describe('with renderDataPoints enabled', () => {
beforeEach(() => {
chart
.renderDataPoints(true)
.renderTitle(true)
.boxWidth(100)
.render();
chart.renderDataPoints(true).renderTitle(true).boxWidth(100).render();
});

it('should create one data point per data value (non-outlier)', () => {
Expand All @@ -101,8 +103,8 @@ describe('dc.BoxPlot', () => {
});
it('should display the data between 10 to 90 of the box (by default)', () => {
const w = box(1).select('rect.box').attr('width');
const min = (w / 2) - (w * chart.dataWidthPortion() / 2);
const max = (w / 2) + (w * chart.dataWidthPortion() / 2);
const min = w / 2 - (w * chart.dataWidthPortion()) / 2;
const max = w / 2 + (w * chart.dataWidthPortion()) / 2;
chart.selectAll('circle.data').each(function () {
expect(d3.select(this).attr('cx')).toBeGreaterThan(min - 0.1);
expect(d3.select(this).attr('cx')).toBeLessThan(max + 0.1);
Expand All @@ -111,15 +113,13 @@ describe('dc.BoxPlot', () => {

describe('and dataWidthPortion set to 50%', () => {
beforeEach(() => {
chart
.dataWidthPortion(0.5)
.render();
chart.dataWidthPortion(0.5).render();
});

it('should display the data between 25 to 75 of the box', () => {
const w = box(1).select('rect.box').attr('width');
const min = (w / 2) - (w * chart.dataWidthPortion() / 2);
const max = (w / 2) + (w * chart.dataWidthPortion() / 2);
const min = w / 2 - (w * chart.dataWidthPortion()) / 2;
const max = w / 2 + (w * chart.dataWidthPortion()) / 2;
chart.selectAll('circle.data').each(function () {
expect(d3.select(this).attr('cx')).toBeGreaterThan(min - 0.1);
expect(d3.select(this).attr('cx')).toBeLessThan(max + 0.1);
Expand All @@ -129,15 +129,13 @@ describe('dc.BoxPlot', () => {

describe('and dataWidthPortion set to 10%', () => {
beforeEach(() => {
chart
.dataWidthPortion(0.1)
.render();
chart.dataWidthPortion(0.1).render();
});

it('should display the data between 45 to 55 of the box', () => {
const w = box(1).select('rect.box').attr('width');
const min = (w / 2) - (w * chart.dataWidthPortion() / 2);
const max = (w / 2) + (w * chart.dataWidthPortion() / 2);
const min = w / 2 - (w * chart.dataWidthPortion()) / 2;
const max = w / 2 + (w * chart.dataWidthPortion()) / 2;
chart.selectAll('circle.data').each(function () {
expect(d3.select(this).attr('cx')).toBeGreaterThan(min - 0.1);
expect(d3.select(this).attr('cx')).toBeLessThan(max + 0.1);
Expand Down Expand Up @@ -170,7 +168,9 @@ describe('dc.BoxPlot', () => {
});

it('should be settable to a function', () => {
chart.boxWidth((innerChartWidth, xUnits) => innerChartWidth / (xUnits + 2)).render();
chart
.boxWidth((innerChartWidth, xUnits) => innerChartWidth / (xUnits + 2))
.render();
expect(box(1).select('rect.box').attr('width')).toBe('75');
});
});
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('dc.BoxPlot', () => {
});
});

function box (n) {
function box(n) {
const nthBox = d3.select(chart.selectAll('g.box').nodes()[n]);
nthBox.boxText = function (i) {
return d3.select(this.selectAll('text.box').nodes()[i]);
Expand All @@ -305,4 +305,3 @@ describe('dc.BoxPlot', () => {
return nthBox;
}
});

Loading

0 comments on commit ee9dd26

Please sign in to comment.