Skip to content

Commit b3135e3

Browse files
committed
Fix linter errors with specs
1 parent 509ff83 commit b3135e3

31 files changed

+2420
-2360
lines changed

.jshintrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
"global": false,
6767
"module": false,
6868
"process": false,
69-
"require": false
69+
"require": false,
70+
"jasmine": false,
71+
"expect": false,
72+
"describe": false,
73+
"it": false,
74+
"beforeEach": false,
75+
"afterEach": false,
76+
"spyOn": false
7077
}
7178
}

spec/bar-chart-spec.js

Lines changed: 316 additions & 314 deletions
Large diffs are not rendered by default.

spec/base-mixin-spec.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
describe("dc.baseMixin", function () {
1+
/* global appendChartID, flushAllD3Transitions, loadDateFixture */
2+
describe('dc.baseMixin', function () {
23
var id, chart, dimension, group, addFilterHandler, removeFilterHandler, hasFilterHandler, resetFilterHandler;
34

45
beforeEach(function () {
@@ -43,27 +44,27 @@ describe("dc.baseMixin", function () {
4344
chart.on('pretransition.pret', pretransition);
4445
});
4546

46-
it('should not execute a renderlet until after the render transitions', function() {
47+
it('should not execute a renderlet until after the render transitions', function () {
4748
chart.render();
4849
expect(firstRenderlet).not.toHaveBeenCalled();
4950
flushAllD3Transitions();
5051
expect(firstRenderlet).toHaveBeenCalled();
5152
});
5253

53-
it('should not execute a renderlet until after the redraw transitions', function() {
54+
it('should not execute a renderlet until after the redraw transitions', function () {
5455
chart.redraw();
5556
expect(firstRenderlet).not.toHaveBeenCalled();
5657
flushAllD3Transitions();
5758
expect(firstRenderlet).toHaveBeenCalled();
5859
});
5960

60-
it('should execute pretransition event before the render transitions', function() {
61+
it('should execute pretransition event before the render transitions', function () {
6162
chart.render();
6263
expect(pretransition).toHaveBeenCalled();
6364
flushAllD3Transitions();
6465
});
6566

66-
it('should execute pretransition event before the redraw transitions', function() {
67+
it('should execute pretransition event before the redraw transitions', function () {
6768
chart.redraw();
6869
expect(pretransition).toHaveBeenCalled();
6970
flushAllD3Transitions();
@@ -143,7 +144,7 @@ describe("dc.baseMixin", function () {
143144
describe('on filter double', function () {
144145
var filterSpy, filterSpy2, filter;
145146
beforeEach(function () {
146-
filter = "1";
147+
filter = '1';
147148

148149
var expectedCallbackSignature = function (callbackChart, callbackFilter) {
149150
expect(callbackChart).toBe(chart);
@@ -152,8 +153,8 @@ describe("dc.baseMixin", function () {
152153

153154
filterSpy = jasmine.createSpy().and.callFake(expectedCallbackSignature);
154155
filterSpy2 = jasmine.createSpy().and.callFake(expectedCallbackSignature);
155-
chart.on("filtered.one", filterSpy);
156-
chart.on("filtered.two", filterSpy2);
156+
chart.on('filtered.one', filterSpy);
157+
chart.on('filtered.two', filterSpy2);
157158
});
158159

159160
it('should execute first callback after setting through #filter', function () {
@@ -175,15 +176,15 @@ describe("dc.baseMixin", function () {
175176
describe('on filter', function () {
176177
var filterSpy, filter;
177178
beforeEach(function () {
178-
filter = "1";
179+
filter = '1';
179180

180181
var expectedCallbackSignature = function (callbackChart, callbackFilter) {
181182
expect(callbackChart).toBe(chart);
182183
expect(callbackFilter).toEqual(filter);
183184
};
184185

185186
filterSpy = jasmine.createSpy().and.callFake(expectedCallbackSignature);
186-
chart.on("filtered", filterSpy);
187+
chart.on('filtered', filterSpy);
187188
});
188189

189190
it('should execute callback after setting through #filter', function () {
@@ -207,8 +208,8 @@ describe("dc.baseMixin", function () {
207208
preRedrawSpy = jasmine.createSpy().and.callFake(expectedCallbackSignature);
208209
postRedrawSpy = jasmine.createSpy().and.callFake(expectedCallbackSignature);
209210

210-
chart.on("preRedraw", preRedrawSpy);
211-
chart.on("postRedraw", postRedrawSpy);
211+
chart.on('preRedraw', preRedrawSpy);
212+
chart.on('postRedraw', postRedrawSpy);
212213
});
213214

214215
it('should execute the preRedraw callback before transitions', function () {
@@ -231,7 +232,7 @@ describe("dc.baseMixin", function () {
231232
it('should require dimension', function () {
232233
try {
233234
dc.baseMixin({}).group(group).render();
234-
throw new Error("That should've thrown");
235+
throw new Error('That should\'ve thrown');
235236
} catch (e) {
236237
expect(e instanceof dc.errors.InvalidStateException).toBeTruthy();
237238
}
@@ -240,7 +241,7 @@ describe("dc.baseMixin", function () {
240241
it('should require group', function () {
241242
try {
242243
dc.baseMixin({}).dimension(dimension).render();
243-
throw new Error("That should've thrown");
244+
throw new Error('That should\'ve thrown');
244245
} catch (e) {
245246
expect(e instanceof dc.errors.InvalidStateException).toBeTruthy();
246247
}
@@ -251,14 +252,14 @@ describe("dc.baseMixin", function () {
251252
var id;
252253

253254
beforeEach(function () {
254-
id = "chart-id";
255+
id = 'chart-id';
255256
});
256257

257258
describe('using a d3 node', function () {
258259
var anchorDiv;
259260

260261
beforeEach(function () {
261-
anchorDiv = d3.select("body").append("div").attr("id", id).node();
262+
anchorDiv = d3.select('body').append('div').attr('id', id).node();
262263
chart.anchor(anchorDiv);
263264
});
264265

@@ -276,8 +277,8 @@ describe("dc.baseMixin", function () {
276277

277278
describe('without an id', function () {
278279
beforeEach(function () {
279-
d3.select("#" + id).remove();
280-
anchorDiv = d3.select("body").append("div").attr("class", "no-id").node();
280+
d3.select('#' + id).remove();
281+
anchorDiv = d3.select('body').append('div').attr('class', 'no-id').node();
281282
chart.anchor(anchorDiv);
282283
});
283284

@@ -295,12 +296,12 @@ describe("dc.baseMixin", function () {
295296

296297
describe('using an id selector', function () {
297298
beforeEach(function () {
298-
d3.select("body").append("div").attr("id", id);
299+
d3.select('body').append('div').attr('id', id);
299300
chart.anchor('#' + id);
300301
});
301302

302303
it('should add the dc chart class to its parent div', function () {
303-
expect(chart.root().classed("dc-chart")).toBeTruthy();
304+
expect(chart.root().classed('dc-chart')).toBeTruthy();
304305
});
305306

306307
it('should return the id selector when anchor is called', function () {
@@ -351,11 +352,11 @@ describe("dc.baseMixin", function () {
351352
chart.width(300).height(301).render();
352353
});
353354

354-
it("should set the height", function () {
355+
it('should set the height', function () {
355356
expect(chart.height()).toEqual(301);
356357
});
357358

358-
it("should set the width", function () {
359+
it('should set the width', function () {
359360
expect(chart.width()).toEqual(300);
360361
});
361362
});

spec/biggish-data-spec.js

Lines changed: 19 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/box-plot-spec.js

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
describe('dc.boxPlot', function() {
1+
/* global appendChartID, loadBoxPlotFixture */
2+
describe('dc.boxPlot', function () {
23
var id, chart;
34
var data, dimension, group;
45

@@ -33,127 +34,127 @@ describe('dc.boxPlot', function() {
3334
chart.render();
3435
});
3536

36-
it('should create a non-empty SVG node', function() {
37+
it('should create a non-empty SVG node', function () {
3738
expect(chart.svg().empty()).toBeFalsy();
3839
});
3940

40-
it('should create one outlier circle per outlier', function() {
41+
it('should create one outlier circle per outlier', function () {
4142
expect(chart.selectAll('circle.outlier').size()).toBe(2);
4243
});
4344

44-
it('should create an offset box for each dimension in the group', function() {
45+
it('should create an offset box for each dimension in the group', function () {
4546
expect(box(0).attr('transform')).toMatchTranslate(50,0);
4647
expect(box(1).attr('transform')).toMatchTranslate(150,0);
4748
});
4849

49-
it('should correctly place median line', function() {
50+
it('should correctly place median line', function () {
5051
expect(box(1).selectAll('line.median').attr('y1')).toBe('100');
5152
expect(box(1).selectAll('line.median').attr('y2')).toBe('100');
5253
});
5354

54-
it('should set the median value correctly', function() {
55+
it('should set the median value correctly', function () {
5556
expect(box(1).boxText(1).text()).toBe('44');
5657
});
5758

58-
it('should place the left box line at the x origin', function() {
59+
it('should place the left box line at the x origin', function () {
5960
expect(box(1).select('rect.box').attr('x')).toBe('0');
6061
});
6162

6263
describe('the width of the box plot', function () {
63-
it('should default to being based on the rangeBand', function() {
64+
it('should default to being based on the rangeBand', function () {
6465
expect(box(1).select('rect.box').attr('width')).toBe('100');
6566
});
6667

67-
it('should be settable to a number', function() {
68+
it('should be settable to a number', function () {
6869
chart.boxWidth(150).render();
6970
expect(box(1).select('rect.box').attr('width')).toBe('150');
7071
});
7172

72-
it('should be settable to a function', function() {
73-
chart.boxWidth(function(innerChartWidth, xUnits) {
73+
it('should be settable to a function', function () {
74+
chart.boxWidth(function (innerChartWidth, xUnits) {
7475
return innerChartWidth / (xUnits + 2);
7576
}).render();
7677
expect(box(1).select('rect.box').attr('width')).toBe('75');
7778
});
7879
});
7980

8081
describe('the tickFormat of the box plot', function () {
81-
it('should default to whole number', function() {
82+
it('should default to whole number', function () {
8283
expect(box(1).boxText(1).text()).toBe('44');
8384
expect(box(1).whiskerText(0).text()).toBe('22');
8485
expect(box(1).whiskerText(1).text()).toBe('66');
8586
});
8687

87-
it('should be settable to a d3.format', function() {
88-
chart.tickFormat(d3.format(".2f")).render();
88+
it('should be settable to a d3.format', function () {
89+
chart.tickFormat(d3.format('.2f')).render();
8990
expect(box(1).boxText(1).text()).toBe('44.00');
9091
expect(box(1).whiskerText(0).text()).toBe('22.00');
9192
expect(box(1).whiskerText(1).text()).toBe('66.00');
9293
});
9394
});
9495

95-
it('should place interquartile range lines after the first and before the fourth quartile', function() {
96+
it('should place interquartile range lines after the first and before the fourth quartile', function () {
9697
expect(box(1).select('rect.box').attr('y')).toBe('94.5');
9798
expect(box(1).select('rect.box').attr('height')).toBe('16.5');
9899
});
99100

100-
it('should label the interquartile range lines using their calculated values', function() {
101+
it('should label the interquartile range lines using their calculated values', function () {
101102
expect(box(1).boxText(0).text()).toBe('33');
102103
expect(box(1).boxText(2).text()).toBe('50');
103104
});
104105

105-
it('should place the whiskers at 1.5x the interquartile range', function() {
106+
it('should place the whiskers at 1.5x the interquartile range', function () {
106107
expect(box(1).whiskerLine(0).attr('y1')).toBe('122');
107108
expect(box(1).whiskerLine(0).attr('y2')).toBe('122');
108109
expect(box(1).whiskerLine(1).attr('y1')).toBeWithinDelta(78);
109110
expect(box(1).whiskerLine(1).attr('y2')).toBeWithinDelta(78);
110111
});
111112

112-
it('should label the whiskers using their calculated values', function() {
113+
it('should label the whiskers using their calculated values', function () {
113114
expect(box(1).whiskerText(0).text()).toBe('22');
114115
expect(box(1).whiskerText(1).text()).toBe('66');
115116
});
116117

117-
it('should assign a fill color to the boxes', function() {
118-
expect(box(0).select('rect.box').attr("fill")).toBe("#01");
119-
expect(box(1).select('rect.box').attr("fill")).toBe("#02");
118+
it('should assign a fill color to the boxes', function () {
119+
expect(box(0).select('rect.box').attr('fill')).toBe('#01');
120+
expect(box(1).select('rect.box').attr('fill')).toBe('#02');
120121
});
121122

122-
describe('when a box has no data', function() {
123+
describe('when a box has no data', function () {
123124
var firstBox;
124125

125-
beforeEach(function() {
126+
beforeEach(function () {
126127
firstBox = chart.select('g.box').node();
127128
var otherDimension = data.dimension(function (d) { return d.countrycode; });
128-
otherDimension.filter("US");
129+
otherDimension.filter('US');
129130
chart.redraw();
130131
});
131132

132-
it('should not attempt to render that box', function() {
133+
it('should not attempt to render that box', function () {
133134
expect(chart.selectAll('g.box').size()).toBe(1);
134135
});
135136

136-
it('should not animate the removed box into another box', function() {
137+
it('should not animate the removed box into another box', function () {
137138
expect(chart.select('g.box').node()).not.toBe(firstBox);
138139
});
139140

140-
describe("with elasticX enabled", function() {
141-
beforeEach(function() {
141+
describe('with elasticX enabled', function () {
142+
beforeEach(function () {
142143
chart.elasticX(true).render();
143144
});
144145

145-
it('should not represent the box in the chart domain', function() {
146-
expect(chart.selectAll(".axis.x .tick").size()).toBe(1);
146+
it('should not represent the box in the chart domain', function () {
147+
expect(chart.selectAll('.axis.x .tick').size()).toBe(1);
147148
});
148149
});
149150

150-
describe("when elasticX is disabled", function() {
151-
beforeEach(function() {
151+
describe('when elasticX is disabled', function () {
152+
beforeEach(function () {
152153
chart.elasticX(false).render();
153154
});
154155

155-
it('should represent the box in the chart domain', function() {
156-
expect(chart.selectAll(".axis.x .tick").size()).toBe(2);
156+
it('should represent the box in the chart domain', function () {
157+
expect(chart.selectAll('.axis.x .tick').size()).toBe(2);
157158
});
158159
});
159160
});
@@ -166,18 +167,18 @@ describe('dc.boxPlot', function() {
166167

167168
describe('filtering the box plot', function () {
168169
beforeEach(function () {
169-
chart.filter("CA").redraw();
170+
chart.filter('CA').redraw();
170171
});
171172

172-
it('should select the boxes corresponding to the filtered value', function() {
173+
it('should select the boxes corresponding to the filtered value', function () {
173174
box(0).each(function (d) {
174-
expect(d3.select(this).classed("selected")).toBeTruthy();
175+
expect(d3.select(this).classed('selected')).toBeTruthy();
175176
});
176177
});
177178

178-
it('should deselect the boxes not corresponding to the filtered value', function() {
179+
it('should deselect the boxes not corresponding to the filtered value', function () {
179180
box(1).each(function (d) {
180-
expect(d3.select(this).classed("deselected")).toBeTruthy();
181+
expect(d3.select(this).classed('deselected')).toBeTruthy();
181182
});
182183
});
183184
});
@@ -187,21 +188,21 @@ describe('dc.boxPlot', function() {
187188
box(0).on('click').call(chart, box(0).datum());
188189
});
189190

190-
it('should apply a filter to the chart', function() {
191-
expect(chart.hasFilter("CA")).toBeTruthy();
191+
it('should apply a filter to the chart', function () {
192+
expect(chart.hasFilter('CA')).toBeTruthy();
192193
});
193194
});
194195
});
195196

196-
function box(n) {
197+
function box (n) {
197198
var nthBox = d3.select(chart.selectAll('g.box')[0][n]);
198-
nthBox.boxText = function(n) {
199+
nthBox.boxText = function (n) {
199200
return d3.select(this.selectAll('text.box')[0][n]);
200201
};
201-
nthBox.whiskerLine = function(n) {
202+
nthBox.whiskerLine = function (n) {
202203
return d3.select(this.selectAll('line.whisker')[0][n]);
203204
};
204-
nthBox.whiskerText = function(n) {
205+
nthBox.whiskerText = function (n) {
205206
return d3.select(this.selectAll('text.whisker')[0][n]);
206207
};
207208
return nthBox;

0 commit comments

Comments
 (0)