Skip to content

Commit

Permalink
Fix the coverage collecting
Browse files Browse the repository at this point in the history
  • Loading branch information
emonkak committed Sep 24, 2016
1 parent cdb8362 commit 78c71a0
Show file tree
Hide file tree
Showing 72 changed files with 186 additions and 175 deletions.
12 changes: 10 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"plugins": ["transform-runtime"],
"presets": ["es2015", "stage-0"]
"plugins": [
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
]
],
"presets": ["es2015", "stage-0"]
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ script:
- npm test
- npm run lint
after_success:
- npm run cover
- npm run coverage
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
cache:
directories:
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "Provides the individual methods of LINQ as a module",
"main": "index.js",
"scripts": {
"build": "tsc --declaration --rootDir src --outDir dist && cp LICENSE README.md package.json dist/",
"build": "tsc --declaration && cp LICENSE README.md package.json dist/",
"clean": "rm -fr coverage dist",
"cover": "isparta cover --include-all-sources --report lcovonly --report html --report text ./node_modules/mocha/bin/_mocha -- --compilers js:babel-core/register",
"coverage": "babel-node ./node_modules/.bin/istanbul cover --include-all-sources _mocha -- --compilers js:babel-core/register --recursive && remap-istanbul -i coverage/coverage.json -t lcovonly -o coverage/lcov.info",
"lint": "tslint src/**/*.ts",
"test": "mocha --compilers js:babel-core/register --recursive",
"watch": "tsc --watch --rootDir src --outDir dist"
"watch": "tsc --watch"
},
"author": "Shota Nozaki",
"license": "MIT",
Expand All @@ -19,16 +19,17 @@
},
"homepage": "https://github.com/emonkak/js-enumerable",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.4.5",
"babel-plugin-transform-runtime": "^6.7.5",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.3.13",
"babel-runtime": "^6.6.1",
"cash-cp": "^0.2.0",
"cash-rm": "^0.2.0",
"coveralls": "^2.11.9",
"isparta": "^4.0.0",
"istanbul": "^0.4.5",
"mocha": "^3.0.2",
"remap-istanbul": "^0.6.4",
"sinon": "^1.17.3",
"tslint": "^3.10.2",
"typescript": "^2.0.3"
Expand Down
4 changes: 2 additions & 2 deletions test/aggregateTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import aggregate from '../dist/aggregate';
import assert from 'assert';

describe('aggregate()', function() {
it('should applies an accumulator function over a sequence', function() {
describe('aggregate()', () => {
it('should applies an accumulator function over a sequence', () => {
assert.strictEqual([1, 2, 3, 4]::aggregate(0, (total, n) => total + n), 10);
assert.strictEqual([]::aggregate(2, (total, n) => total + n), 2);
});
Expand Down
4 changes: 2 additions & 2 deletions test/allTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import all from '../dist/all';
import assert from 'assert';

describe('all()', function() {
it('should determines whether all elements of a sequence satisfy a condition', function() {
describe('all()', () => {
it('should determines whether all elements of a sequence satisfy a condition', () => {
assert.strictEqual([1, 2, 3, 4]::all(), true);
assert.strictEqual([2, 4]::all(n => n % 2 === 0), true);
assert.strictEqual([0, 1, 2, 3]::all(n => n % 2 === 0), false);
Expand Down
4 changes: 2 additions & 2 deletions test/anyTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import any from '../dist/any';
import assert from 'assert';

describe('any()', function() {
it('should determines whether a sequence contains any elements', function() {
describe('any()', () => {
it('should determines whether a sequence contains any elements', () => {
assert.strictEqual([0, 1, 2, 3, 4]::any(), true);
assert.strictEqual([1, 2, 3, 4]::any(n => n % 2 === 0), true);
assert.strictEqual([0]::any(), false);
Expand Down
6 changes: 3 additions & 3 deletions test/averageTest.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import assert from 'assert';
import average from '../dist/average';

describe('average()', function() {
it('should computes the average of a sequence of numbers', function() {
describe('average()', () => {
it('should computes the average of a sequence of numbers', () => {
assert.strictEqual([0, 1, 2, 3, 4]::average(), 2);
assert.strictEqual([0, 1, 2, 3, 4]::average(n => n * 2), 4);
});

it('should throws the exception if the sequence contains no elements', function() {
it('should throws the exception if the sequence contains no elements', () => {
assert.throws(() => []::average(), Error);
assert.throws(() => []::average(n => n * 2), Error);
});
Expand Down
6 changes: 3 additions & 3 deletions test/bufferTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import buffer from '../dist/buffer';

describe('buffer()', function() {
it('should generates a sequence of non-overlapping adjacent buffers over the source sequence', function() {
describe('buffer()', () => {
it('should generates a sequence of non-overlapping adjacent buffers over the source sequence', () => {
const xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert.deepEqual(Array.from(xs::buffer(3)), [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]);
assert.deepEqual(Array.from(xs::buffer(5)), [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]);
Expand All @@ -11,7 +11,7 @@ describe('buffer()', function() {
assert.deepEqual(Array.from(xs::buffer(3, 4)), [[0, 1, 2], [4, 5, 6], [8, 9]]);
});

it('should throws the exception if "count" or "skip" arguments is less than or equal to 0', function() {
it('should throws the exception if "count" or "skip" arguments is less than or equal to 0', () => {
assert.throws(() => Array.from([]::buffer(0)), RangeError);
assert.throws(() => Array.from([]::buffer(1, 0)), RangeError);
assert.throws(() => Array.from([]::buffer(0, 1)), RangeError);
Expand Down
6 changes: 3 additions & 3 deletions test/catchTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import _catch from '../dist/catch';
import assert from 'assert';
import sinon from 'sinon';

describe('catch()', function() {
it('should creates a sequence that corresponds to the source sequence', function() {
describe('catch()', () => {
it('should creates a sequence that corresponds to the source sequence', () => {
const xs = [1, 2, 3];
const ys = [4, 5, 6];
const handler = sinon.spy(e => ys);
assert.deepEqual(Array.from(xs::_catch(handler)), [1, 2, 3]);
sinon.assert.notCalled(handler);
});

it('should concatenate it with the sequence resulting from calling an exception handler function in case of an error', function() {
it('should concatenate it with the sequence resulting from calling an exception handler function in case of an error', () => {
const xs = {
[Symbol.iterator]: function*() {
yield 1
Expand Down
4 changes: 2 additions & 2 deletions test/concatTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import concat from '../dist/concat';

describe('concat()', function() {
it('should concatenates two sequences', function() {
describe('concat()', () => {
it('should concatenates two sequences', () => {
assert.deepEqual(Array.from([]::concat([])), []);
assert.deepEqual(Array.from([1, 2, 3]::concat([4, 5, 6])), [1, 2, 3, 4, 5, 6]);
assert.deepEqual(Array.from([1, 2, 3]::concat([4, 5, 6], [7, 8, 9])), [1, 2, 3, 4, 5, 6, 7, 8, 9]);
Expand Down
4 changes: 2 additions & 2 deletions test/countTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import count from '../dist/count';

describe('count()', function() {
it('should returns the number of elements in a sequence', function() {
describe('count()', () => {
it('should returns the number of elements in a sequence', () => {
assert.strictEqual([1, 2, 3, 4]::count(), 4);
assert.strictEqual([1, 2, 3, 4][Symbol.iterator]()::count(), 4);
assert.strictEqual([]::count(), 0);
Expand Down
6 changes: 3 additions & 3 deletions test/defaultIfEmptyTest.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import assert from 'assert';
import defaultIfEmpty from '../dist/defaultIfEmpty';

describe('defaultIfEmpty()', function() {
it('should returns the elements of the specified sequence', function() {
describe('defaultIfEmpty()', () => {
it('should returns the elements of the specified sequence', () => {
assert.deepEqual(Array.from([1, 2, 3]::defaultIfEmpty(123)), [1, 2, 3]);
});

it('should returns the specified value in a singleton collection if the sequence is empty', function() {
it('should returns the specified value in a singleton collection if the sequence is empty', () => {
assert.deepEqual(Array.from([]::defaultIfEmpty(123)), [123]);
});
});
4 changes: 2 additions & 2 deletions test/distinctTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import distinct from '../dist/distinct';

describe('distinct()', function() {
it('should returns distinct elements from a sequence', function() {
describe('distinct()', () => {
it('should returns distinct elements from a sequence', () => {
assert.deepEqual(Array.from([1, 2, 1, 2]::distinct()), [1, 2]);
assert.deepEqual(Array.from([1, 1, 2, 2]::distinct()), [1, 2]);
assert.deepEqual(Array.from([1, 2, 3, 4]::distinct(x => x % 2 === 0)), [1, 2]);
Expand Down
4 changes: 2 additions & 2 deletions test/distinctUntilChangedTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import distinctUntilChanged from '../dist/distinctUntilChanged';

describe('distinctUntilChanged()', function() {
it('should returns consecutive distinct elements', function() {
describe('distinctUntilChanged()', () => {
it('should returns consecutive distinct elements', () => {
assert.deepEqual(Array.from([1, 2, 1, 2]::distinctUntilChanged()), [1, 2, 1, 2]);
assert.deepEqual(Array.from([1, 1, 2, 2]::distinctUntilChanged()), [1, 2]);
assert.deepEqual(Array.from([1, 2, 3, 4]::distinctUntilChanged(x => x % 2 === 0)), [1, 2, 3, 4]);
Expand Down
4 changes: 2 additions & 2 deletions test/doTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import _do from '../dist/do';
import assert from 'assert';
import sinon from 'sinon';

describe('do()', function() {
it('should lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination', function() {
describe('do()', () => {
it('should lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination', () => {
const spy = sinon.spy();
const result = [1, 2, 3, 4]::_do(spy);
sinon.assert.notCalled(spy);
Expand Down
4 changes: 2 additions & 2 deletions test/doWhileTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import doWhile from '../dist/doWhile';

describe('doWhile()', function() {
it('should generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds', function() {
describe('doWhile()', () => {
it('should generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds', () => {
let x = 0;
const xs = {
[Symbol.iterator]: function*() {
Expand Down
8 changes: 4 additions & 4 deletions test/elementAtOrDefaultTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import orderBy from '../dist/orderBy';
import skip from '../dist/skip';
import take from '../dist/take';

describe('elementAtOrDefault()', function() {
it('should returns the element at a specified index in a sequence', function() {
describe('elementAtOrDefault()', () => {
it('should returns the element at a specified index in a sequence', () => {
const xs = [1, 2, 3, 4];

assert.strictEqual(xs::elementAtOrDefault(0), 1);
Expand All @@ -14,14 +14,14 @@ describe('elementAtOrDefault()', function() {
assert.strictEqual(xs::elementAtOrDefault(3), 4);
});

it('should returns a default value if the index is out of range', function() {
it('should returns a default value if the index is out of range', () => {
const xs = [1, 2, 3, 4];

assert.strictEqual(xs::elementAtOrDefault(4, 123), 123);
assert.strictEqual(xs::elementAtOrDefault(4), null);
});

it('should works with orderBy()', function() {
it('should works with orderBy()', () => {
const xs = [3, 2, 4, 1];

assert.strictEqual(xs::orderBy()::elementAtOrDefault(0), 1);
Expand Down
8 changes: 4 additions & 4 deletions test/elementAtTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import orderBy from '../dist/orderBy';
import skip from '../dist/skip';
import take from '../dist/take';

describe('elementAt()', function() {
it('should returns the element at a specified index in a sequence', function() {
describe('elementAt()', () => {
it('should returns the element at a specified index in a sequence', () => {
const xs = [1, 2, 3, 4];

assert.strictEqual(xs::elementAt(0), 1);
Expand All @@ -14,13 +14,13 @@ describe('elementAt()', function() {
assert.strictEqual(xs::elementAt(3), 4);
});

it('should throws the exception if index is out of range', function() {
it('should throws the exception if index is out of range', () => {
const xs = [1, 2, 3, 4];

assert.throws(() => xs::elementAt(4));
});

it('should works with orderBy()', function() {
it('should works with orderBy()', () => {
const xs = [3, 2, 4, 1];

assert.strictEqual(xs::orderBy()::elementAt(0), 1);
Expand Down
4 changes: 2 additions & 2 deletions test/exceptTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import except from '../dist/except';

describe('except()', function() {
it('should produces the set difference of two sequences', function() {
describe('except()', () => {
it('should produces the set difference of two sequences', () => {
assert.deepEqual(Array.from([]::except([])), []);
assert.deepEqual(Array.from([1, 2, 3, 4, 5, 6]::except([2, 3, 4])), [1, 5, 6]);
assert.deepEqual(Array.from([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]::except([2, 3, 4])), [1, 5, 6]);
Expand Down
4 changes: 2 additions & 2 deletions test/finallyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import _finally from '../dist/finally';
import assert from 'assert';
import sinon from 'sinon';

describe('finally()', function() {
it('should creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed', function() {
describe('finally()', () => {
it('should creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed', () => {
const source1 = [1, 2, 3];
const finallyAction1 = sinon.spy();
assert.deepEqual(Array.from(source1::_finally(finallyAction1)), [1, 2, 3]);
Expand Down
8 changes: 4 additions & 4 deletions test/firstOrDefaultTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import orderBy from '../dist/orderBy';
import skip from '../dist/skip';
import take from '../dist/take';

describe('firstOrDefault()', function() {
it('should returns the first element of a sequence', function() {
describe('firstOrDefault()', () => {
it('should returns the first element of a sequence', () => {
assert.strictEqual([1, 2, 3, 4]::firstOrDefault(), 1);
assert.strictEqual([1, 2, 3, 4]::firstOrDefault(x => x % 2 === 0), 2);
});

it('should returns a default value if the sequence contains no elements', function() {
it('should returns a default value if the sequence contains no elements', () => {
assert.strictEqual([]::firstOrDefault(), null);
assert.strictEqual([]::firstOrDefault(null, 123), 123);
assert.strictEqual([1, 2, 3, 4]::firstOrDefault(x => x > 10), null);
assert.strictEqual([1, 2, 3, 4]::firstOrDefault(x => x > 10, 123), 123);
});

it('should works with orderBy()', function() {
it('should works with orderBy()', () => {
const xs = [3, 2, 4, 1];
assert.strictEqual(xs::orderBy()::firstOrDefault(), 1);
assert.strictEqual(xs::orderBy()::take(2)::firstOrDefault(), 1);
Expand Down
8 changes: 4 additions & 4 deletions test/firstTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import orderBy from '../dist/orderBy';
import skip from '../dist/skip';
import take from '../dist/take';

describe('first()', function() {
it('should returns the first element of a sequence', function() {
describe('first()', () => {
it('should returns the first element of a sequence', () => {
assert.strictEqual([1, 2, 3, 4]::first(), 1);
assert.strictEqual([1, 2, 3, 4]::first(x => x % 2 === 0), 2);
});

it('should throws the exception if the sequence contains no elements', function() {
it('should throws the exception if the sequence contains no elements', () => {
assert.throws(() => []::first());
assert.throws(() => [1, 2, 3, 4]::first(x => x > 10));
});

it('should works with orderBy()', function() {
it('should works with orderBy()', () => {
const xs = [3, 2, 4, 1];
assert.strictEqual(xs::orderBy()::first(), 1);
assert.strictEqual(xs::orderBy()::take(2)::first(), 1);
Expand Down
4 changes: 2 additions & 2 deletions test/forEachTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import forEach from '../dist/forEach';
import sinon from 'sinon';

describe('forEach()', function() {
it('should enumerates the sequence and invokes the given action for each value in the sequence', function() {
describe('forEach()', () => {
it('should enumerates the sequence and invokes the given action for each value in the sequence', () => {
const spy = sinon.spy();
const xs = [1, 2, 3, 4];
xs::forEach(e => spy(e));
Expand Down
4 changes: 2 additions & 2 deletions test/groupByTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import groupBy from '../dist/groupBy';

describe('groupBy()', function() {
it('should groups the elements of a sequence according to a specified key selector function', function() {
describe('groupBy()', () => {
it('should groups the elements of a sequence according to a specified key selector function', () => {
let result = [1, 2, 3, 4]::groupBy(x => x % 2 === 0 ? 'even' : 'odd');
assert.deepEqual(Array.from(result), [['odd', [1, 3]], ['even', [2, 4]]]);

Expand Down
4 changes: 2 additions & 2 deletions test/groupJoinTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import groupJoin from '../dist/groupJoin';

describe('groupJoin()', function() {
it('should correlates the elements of two sequences based on equality of keys and groups the results', function() {
describe('groupJoin()', () => {
it('should correlates the elements of two sequences based on equality of keys and groups the results', () => {
let xs = [0, 1, 2];
let ys = [4, 7, 6, 2, 3, 4, 8, 9];
let result = xs::groupJoin(
Expand Down
Loading

0 comments on commit 78c71a0

Please sign in to comment.