Skip to content

Commit 5fdb235

Browse files
committed
Improve tests CC further
1 parent a570af6 commit 5fdb235

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"coverage": "npm run coverage:generate && npx http-server coverage",
2222
"coverage:generate": "npm run build && npm run coverage:unit && npm run coverage:bdd && npm run coverage:report",
2323
"coverage:check": "npm run build && npm run coverage:unit && npm run coverage:bdd && nyc report --check-coverage",
24-
"coverage:unit": "nyc --silent npm run test:run:unit",
24+
"coverage:unit": "nyc --silent npm run test:run:unit && SCRAMJET_LOG=1 nyc --silent --no-clean npm run test:run:unit -- -m \"trace does not throw\"",
2525
"coverage:bdd": "nyc --silent --no-clean npm run test:run:bdd",
2626
"coverage:report": "nyc report --reporter=html",
2727
"copy": "copyfiles -f test/bdd/features/*.feature build/test/bdd/features && copyfiles -f test/_assets/* build/test/_assets",

src/ifca/ifca-chain.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export class IFCAChain<IN> {
77
*/
88
private chain: Array<IFCA<any, any>> = [];
99

10+
/**
11+
* @returns {number} Length of the IFCAChain (number of IFCA instances in a chain).
12+
*/
13+
get length(): number {
14+
return this.chain.length;
15+
}
16+
1017
/**
1118
* Creates and adds new IFCA to this chain.
1219
*

src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const SCRAMJET_LOG = process.env.SCRAMJET_LOG;
99
* @param {*} [array] Optional array of objects
1010
*/
1111
function trace(msg:any, ...array: any[]) {
12-
// TODO: make this into a const false on compile
1312
if (!SCRAMJET_LOG) return;
1413

1514
const date = new Date();

test/unit/ifca/ifca-chain.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import test from "ava";
2+
import { IFCA } from "../../../src/ifca";
3+
import { IFCAChain } from "../../../src/ifca/ifca-chain";
4+
5+
test("Same IFCA instance would not be duplicated on the IFCAChain end when added twice", async (t) => {
6+
const ifca = new IFCA<number>({});
7+
const ifcaChain = new IFCAChain<number>();
8+
9+
t.is(ifcaChain.length, 0);
10+
11+
ifcaChain.add(ifca);
12+
ifcaChain.add(ifca);
13+
14+
t.is(ifcaChain.length, 1);
15+
16+
ifcaChain.create({});
17+
18+
t.is(ifcaChain.length, 2);
19+
});

test/unit/utils.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from "ava";
2-
import { isAsyncFunction } from "../../src/utils";
2+
import { isAsyncFunction, trace } from "../../src/utils";
33
import { TransformFunction } from "../../src/types";
44

55
test("isAsyncFunction correctly detects sync function (function declaration)", t => {
@@ -51,3 +51,9 @@ test.skip("isAsyncFunction correctly detects sync function returning promise", t
5151

5252
t.true(isAsyncFunction(syncPromise));
5353
});
54+
55+
test("trace does not throw", t => {
56+
t.notThrows(() => {
57+
trace("foo");
58+
});
59+
});

0 commit comments

Comments
 (0)