Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emonkak committed Nov 26, 2019
1 parent 8adc0f5 commit 312d131
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"lint": "tslint 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rm -f -r dist",
"precover": "rm -f -r .nyc_output coverage",
"test": "mocha --recursive --compilers ts:ts-node/register",
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha --recursive --require ts-node/register './test/**/*Test.ts'",
"watch": "tsc --watch"
},
"author": "Shota Nozaki",
Expand Down
12 changes: 9 additions & 3 deletions test/catchTest.ts
Expand Up @@ -12,16 +12,22 @@ describe('catch()', () => {
});

it('should concatenate it with the sequence resulting from calling an exception handler function in case of an error', () => {
const xs = {
const xs: Iterable<number> = {
[Symbol.iterator]: function*() {
yield 1;
yield 2;
yield 3;
throw new Error();
}
};
const ys = [4, 5, 6];
const handler = sinon.spy((e: Error) => ys);
const ys: Iterable<number> = {
[Symbol.iterator]: function*() {
yield 4;
yield 5;
yield 6;
}
};
const handler = sinon.spy((e: Error[]) => ys);
assert.deepEqual(new Enumerable(xs).catch(handler).toArray(), [1, 2, 3, 4, 5, 6]);
sinon.assert.called(handler);
sinon.assert.calledWith(handler, sinon.match.instanceOf(Error));
Expand Down
8 changes: 4 additions & 4 deletions test/doTest.ts
Expand Up @@ -9,9 +9,9 @@ describe('do()', () => {
sinon.assert.notCalled(spy);
assert.deepEqual(Array.from(result), [1, 2, 3, 4]);
sinon.assert.callCount(spy, 4);
sinon.assert.calledWith(spy.getCall(0) as sinon.SinonSpy, 1);
sinon.assert.calledWith(spy.getCall(1) as sinon.SinonSpy, 2);
sinon.assert.calledWith(spy.getCall(2) as sinon.SinonSpy, 3);
sinon.assert.calledWith(spy.getCall(3) as sinon.SinonSpy, 4);
sinon.assert.calledWith(spy.getCall(0), 1);
sinon.assert.calledWith(spy.getCall(1), 2);
sinon.assert.calledWith(spy.getCall(2), 3);
sinon.assert.calledWith(spy.getCall(3), 4);
});
});
8 changes: 4 additions & 4 deletions test/forEachTest.ts
Expand Up @@ -7,9 +7,9 @@ describe('forEach()', () => {
const xs = [1, 2, 3, 4];
new Enumerable(xs).forEach(x => spy(x));
sinon.assert.callCount(spy, 4);
sinon.assert.calledWith(spy.getCall(0) as sinon.SinonSpy, 1);
sinon.assert.calledWith(spy.getCall(1) as sinon.SinonSpy, 2);
sinon.assert.calledWith(spy.getCall(2) as sinon.SinonSpy, 3);
sinon.assert.calledWith(spy.getCall(3) as sinon.SinonSpy, 4);
sinon.assert.calledWith(spy.getCall(0), 1);
sinon.assert.calledWith(spy.getCall(1), 2);
sinon.assert.calledWith(spy.getCall(2), 3);
sinon.assert.calledWith(spy.getCall(3), 4);
});
});

0 comments on commit 312d131

Please sign in to comment.