Skip to content

Commit 386fd61

Browse files
getting eslint mostly there
1 parent 0e4a863 commit 386fd61

File tree

3 files changed

+549
-554
lines changed

3 files changed

+549
-554
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "./node_modules/.bin/babel-node --presets=es2015 spec/run.js",
8-
"lint": "./node_modules/.bin/eslint src/*",
8+
"lint": "./node_modules/.bin/eslint src/*js*",
99
"storybook": "start-storybook -p 6006",
1010
"build-storybook": "build-storybook -s public -o .out",
1111
"deploy-storybook": "storybook-to-ghpages"

spec/pivot_spec.js

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe(" utils", function() {
3131
const aoaInput = [ ["a","b"], [1,2], [3,4] ];
3232
const pd = new utils.PivotData({data: aoaInput});
3333

34-
return it("has the correct grand total value", () =>
34+
it("has the correct grand total value", () =>
3535
expect(pd.getAggregator([],[]).value())
3636
.toBe(2)
3737
);
@@ -41,7 +41,7 @@ describe(" utils", function() {
4141
const aoaInput = [ ["a","b"], [1,2], [3,4] ];
4242
const pd = new utils.PivotData({data: aoaInput, aggregator});
4343

44-
return it("has the correct grand total value", () =>
44+
it("has the correct grand total value", () =>
4545
expect(pd.getAggregator([],[]).value())
4646
.toBe((1+3)/(2+4))
4747
);
@@ -51,7 +51,7 @@ describe(" utils", function() {
5151
const aosInput = [ {a:1, b:2}, {a:3, b:4} ];
5252
const pd = new utils.PivotData({data: aosInput, aggregator});
5353

54-
return it("has the correct grand total value", () =>
54+
it("has the correct grand total value", () =>
5555
expect(pd.getAggregator([],[]).value())
5656
.toBe((1+3)/(2+4))
5757
);
@@ -61,7 +61,7 @@ describe(" utils", function() {
6161
const raggedAosInput = [ {a:1}, {b:4}, {a: 3, b: 2} ];
6262
const pd = new utils.PivotData({data: raggedAosInput, aggregator});
6363

64-
return it("has the correct grand total value", () =>
64+
it("has the correct grand total value", () =>
6565
expect(pd.getAggregator([],[]).value())
6666
.toBe((1+3)/(2+4))
6767
);
@@ -70,19 +70,19 @@ describe(" utils", function() {
7070
describe("with function input", function() {
7171
const functionInput = function(record) {
7272
record({a:1, b:2});
73-
return record({a:3, b:4});
73+
record({a:3, b:4});
7474
};
7575
const pd = new utils.PivotData({data: functionInput, aggregator});
7676

77-
return it("has the correct grand total value", () =>
77+
it("has the correct grand total value", () =>
7878
expect(pd.getAggregator([],[]).value())
7979
.toBe((1+3)/(2+4))
8080
);
8181
});
8282

8383

8484

85-
return describe("with rows/cols", function() {
85+
describe("with rows/cols", function() {
8686
const pd = new utils.PivotData({
8787
data:fixtureData,
8888
rows: ["name", "colour"],
@@ -113,39 +113,36 @@ describe(" utils", function() {
113113
}
114114
expect(numNotNull)
115115
.toBe(4);
116-
return expect(numNull)
116+
expect(numNull)
117117
.toBe(12);
118118
});
119119

120120
it("returns matching records", function() {
121121
const records = [];
122122
pd.forEachMatchingRecord({gender: "male"}, x => records.push(x.name));
123-
return expect(records)
123+
expect(records)
124124
.toEqual(["Nick", "John"]);
125125
});
126126

127127
it("has a correct spot-checked aggregator", function() {
128128
const agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ]);
129129
const val = agg.value();
130130
expect(val).toBe(1);
131-
return expect(agg.format(val)).toBe("1");
131+
expect(agg.format(val)).toBe("1");
132132
});
133133

134-
return it("has a correct grand total aggregator", function() {
134+
it("has a correct grand total aggregator", function() {
135135
const agg = pd.getAggregator([],[]);
136136
const val = agg.value();
137137
expect(val).toBe(4);
138-
return expect(agg.format(val)).toBe("4");
138+
expect(agg.format(val)).toBe("4");
139139
});
140140
});
141141
});
142142

143143
describe(".aggregatorTemplates", function() {
144144

145-
const getVal = function(aggregator) {
146-
const pd = new utils.PivotData({data: fixtureData, aggregator});
147-
return pd.getAggregator([],[]).value();
148-
};
145+
const getVal = (agg) => new utils.PivotData({data: fixtureData, aggregator: agg}).getAggregator([],[]).value();
149146
const tpl = utils.aggregatorTemplates;
150147

151148
describe(".count", () =>
@@ -235,7 +232,7 @@ describe(" utils", function() {
235232
.toBe(98.5);
236233
expect(getVal(tpl.quantile(1/3)(['trials'])))
237234
.toBe(102);
238-
return expect(getVal(tpl.quantile(1)(['trials'])))
235+
expect(getVal(tpl.quantile(1)(['trials'])))
239236
.toBe(112);
240237
})
241238
);
@@ -254,12 +251,19 @@ describe(" utils", function() {
254251
)
255252
);
256253

257-
return describe(".sumOverSum", () =>
254+
describe(".sumOverSum", () =>
258255
it("works", () =>
259256
expect(getVal(tpl.sumOverSum()(['successes', 'trials'])))
260257
.toBe((12+25+30+14)/(95+102+103+112))
261258
)
262259
);
260+
261+
describe(".fractionOf", () =>
262+
it("works", () =>
263+
expect(getVal(tpl.fractionOf(tpl.sum())(['trials'])))
264+
.toBe(1)
265+
)
266+
);
263267
});
264268

265269
describe(".naturalSort()", function() {
@@ -276,7 +280,7 @@ describe(" utils", function() {
276280
'b', 'c', 'd', 'null'
277281
];
278282

279-
return it("sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)", () =>
283+
it("sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)", () =>
280284
expect(sortedArr.slice().sort(naturalSort))
281285
.toEqual(sortedArr)
282286
);
@@ -290,7 +294,7 @@ describe(" utils", function() {
290294
.toEqual([4,3,2,1,5])
291295
);
292296

293-
return it("sorts lowercase after uppercase", () =>
297+
it("sorts lowercase after uppercase", () =>
294298
expect(["Ab","aA","aa","ab"].sort(sortAs(["Ab","Aa"])))
295299
.toEqual(["Ab","ab","aa","aA"])
296300
);
@@ -301,60 +305,60 @@ describe(" utils", function() {
301305

302306
it("formats numbers", function() {
303307
const nf = numberFormat();
304-
return expect(nf(1234567.89123456))
308+
expect(nf(1234567.89123456))
305309
.toEqual("1,234,567.89");
306310
});
307311

308312
it("formats booleans", function() {
309313
const nf = numberFormat();
310-
return expect(nf(true))
314+
expect(nf(true))
311315
.toEqual("1.00");
312316
});
313317

314318
it("formats numbers in strings", function() {
315319
const nf = numberFormat();
316-
return expect(nf("1234567.89123456"))
320+
expect(nf("1234567.89123456"))
317321
.toEqual("1,234,567.89");
318322
});
319323

320324
it("doesn't formats strings", function() {
321325
const nf = numberFormat();
322-
return expect(nf("hi there"))
326+
expect(nf("hi there"))
323327
.toEqual("");
324328
});
325329

326330
it("doesn't formats objects", function() {
327331
const nf = numberFormat();
328-
return expect(nf({a:1}))
332+
expect(nf({a:1}))
329333
.toEqual("");
330334
});
331335

332336
it("formats percentages", function() {
333337
const nf = numberFormat({scaler: 100, suffix: "%"});
334-
return expect(nf(0.12345))
338+
expect(nf(0.12345))
335339
.toEqual("12.35%");
336340
});
337341

338342
it("adds separators", function() {
339343
const nf = numberFormat({thousandsSep: "a", decimalSep: "b"});
340-
return expect(nf(1234567.89123456))
344+
expect(nf(1234567.89123456))
341345
.toEqual("1a234a567b89");
342346
});
343347

344348
it("adds prefixes and suffixes", function() {
345349
const nf = numberFormat({prefix: "a", suffix: "b"});
346-
return expect(nf(1234567.89123456))
350+
expect(nf(1234567.89123456))
347351
.toEqual("a1,234,567.89b");
348352
});
349353

350-
return it("scales and rounds", function() {
354+
it("scales and rounds", function() {
351355
const nf = numberFormat({digitsAfterDecimal: 3, scaler: 1000});
352-
return expect(nf(1234567.89123456))
356+
expect(nf(1234567.89123456))
353357
.toEqual("1,234,567,891.235");
354358
});
355359
});
356360

357-
return describe(".derivers", function() {
361+
describe(".derivers", function() {
358362
describe(".dateFormat()", function() {
359363
const df = utils.derivers.dateFormat("x", "abc % %% %%% %a %y %m %n %d %w %x %H %M %S", true);
360364

@@ -363,16 +367,16 @@ describe(" utils", function() {
363367
.toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11')
364368
);
365369

366-
return it("formats input parsed by Date.parse()", function() {
370+
it("formats input parsed by Date.parse()", function() {
367371
expect(df({x: "2015-01-02T23:43:11Z"}))
368372
.toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11');
369373

370-
return expect(df({x: "bla"}))
374+
expect(df({x: "bla"}))
371375
.toBe('');
372376
});
373377
});
374378

375-
return describe(".bin()", function() {
379+
describe(".bin()", function() {
376380
const binner = utils.derivers.bin("x", 10);
377381

378382
it("bins numbers", function() {
@@ -382,7 +386,7 @@ describe(" utils", function() {
382386
expect(binner({x: 9}))
383387
.toBe(0);
384388

385-
return expect(binner({x: 111}))
389+
expect(binner({x: 111}))
386390
.toBe(110);
387391
});
388392

@@ -401,7 +405,7 @@ describe(" utils", function() {
401405
.toBeNaN()
402406
);
403407

404-
return it("doesn't bin objects", () =>
408+
it("doesn't bin objects", () =>
405409
expect(binner({x: {a:1}}))
406410
.toBeNaN()
407411
);

0 commit comments

Comments
 (0)