Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ jobs:
name: Install dev dependencies
- run: npm run lint
name: Run linter
- run: npm run format:check
name: Run Prettier check
- run: npm run test
name: Run unit tests
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"prepare": "npm run rebuild",
"test": "mocha --exit --timeout 1m \"./test/**/*-specs.ts\"",
"lint": "eslint .",
"format": "prettier -w ./lib",
"format": "prettier -w ./lib ./test",
"format:check": "prettier --check ./lib ./test",
"watch": "npm run dev"
},
"prettier": {
Expand Down
24 changes: 14 additions & 10 deletions test/asyncbox-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ describe('longSleep', function () {
let curElapsed = 0;
let curTimeLeft = 10000;
let curProgress = 0;
const progressCb = function ({elapsedMs, timeLeft, progress}: {elapsedMs: number, timeLeft: number, progress: number}) {
const progressCb = function ({
elapsedMs,
timeLeft,
progress,
}: {
elapsedMs: number;
timeLeft: number;
progress: number;
}) {
expect(elapsedMs).to.be.above(curElapsed);
expect(timeLeft).to.be.below(curTimeLeft);
expect(progress).to.be.above(curProgress);
Expand Down Expand Up @@ -173,7 +181,7 @@ describe('retry', function () {
describe('waitForCondition', function () {
it('should wait and succeed', async function () {
const ref = Date.now();
function condFn (): boolean {
function condFn(): boolean {
return Date.now() - ref > 200;
}
const result = await waitForCondition(condFn, {waitMs: 1000, intervalMs: 10});
Expand All @@ -184,7 +192,7 @@ describe('waitForCondition', function () {
});
it('should wait and fail', async function () {
const ref = Date.now();
function condFn (): boolean {
function condFn(): boolean {
return Date.now() - ref > 200;
}
try {
Expand All @@ -196,7 +204,7 @@ describe('waitForCondition', function () {
});
it('should reduce interval to not exceed timeout', async function () {
const ref = Date.now();
function condFn (): boolean {
function condFn(): boolean {
return Date.now() - ref > 25;
}
await waitForCondition(condFn, {waitMs: 30, intervalMs: 20});
Expand Down Expand Up @@ -241,9 +249,7 @@ describe('asyncmap', function () {
});
it('should raise an error if options is null', async function () {
// @ts-expect-error - testing invalid inputs
await expect(asyncmap(coll, mapper, null)).to.be.rejectedWith(
'Options cannot be null'
);
await expect(asyncmap(coll, mapper, null)).to.be.rejectedWith('Options cannot be null');
});
});

Expand Down Expand Up @@ -283,8 +289,6 @@ describe('asyncfilter', function () {
});
it('should raise an error if options is null', async function () {
// @ts-expect-error - testing invalid inputs
await expect(asyncfilter(coll, filter, null)).to.be.rejectedWith(
'Options cannot be null'
);
await expect(asyncfilter(coll, filter, null)).to.be.rejectedWith('Options cannot be null');
});
});