diff --git a/package.json b/package.json index cef2125..335763f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "prepare": "husky", "build": "tsc", "prepublishOnly": "npm run build", - "test": "xo && tsc --noEmit && c8 ava" + "test": "xo && tsc --noEmit && c8 node --import=tsx/esm --test" }, "files": [ "distribution/main.js", @@ -40,7 +40,6 @@ "@commitlint/config-conventional": "^20.0.0", "@sindresorhus/tsconfig": "^8.0.1", "@types/node": "^24.5.2", - "ava": "^6.4.1", "c8": "^10.1.3", "husky": "^9.1.7", "lint-staged": "^16.2.1", @@ -56,15 +55,6 @@ "lint-staged": { "*.ts": "xo --fix" }, - "ava": { - "extensions": { - "ts": "module" - }, - "nodeArguments": [ - "--import=tsx/esm" - ], - "workerThreads": false - }, "c8": { "reporter": [ "text", diff --git a/test.ts b/test.ts index 3542566..5472def 100644 --- a/test.ts +++ b/test.ts @@ -1,4 +1,5 @@ -import test from 'ava'; +import test from 'node:test'; +import assert from 'node:assert/strict'; import { _, assign, middleware, parallel, passthrough, pipe, } from './main.js'; @@ -8,91 +9,94 @@ const addAge = middleware(async () => ({age: 30})); const addHobby = middleware(() => ({hobby: 'Coding'})); const addScore = middleware(() => ({score: 1000})); -test('should transform data in a pipeline', async t => { +void test('should transform data in a pipeline', async () => { const pipeline = pipe(addAge, addHobby, addScore); const result = await pipeline(await getUser()); - t.deepEqual(result, { + assert.deepEqual(result, { name: 'John Smith', age: 30, hobby: 'Coding', score: 1000, }); }); -test('should transform data in a standalone pipeline', async t => { +void test('should transform data in a standalone pipeline', async () => { const pipeline = pipe(getUser, addAge, addHobby, addScore); const result = await pipeline(_); - t.deepEqual(result, { + assert.deepEqual(result, { name: 'John Smith', age: 30, hobby: 'Coding', score: 1000, }); }); -test('should transform data in a compound pipeline', async t => { +void test('should transform data in a compound pipeline', async () => { const pipeline = pipe(addAge, pipe(addHobby, addScore)); const result = await pipeline(await getUser()); - t.deepEqual(result, { + assert.deepEqual(result, { name: 'John Smith', age: 30, hobby: 'Coding', score: 1000, }); }); -test('should transform data in a compound standalone pipeline', async t => { +void test('should transform data in a compound standalone pipeline', async () => { const pipeline = pipe(getUser, pipe(addAge, addHobby), addScore); const result = await pipeline(_); - t.deepEqual(result, { + assert.deepEqual(result, { name: 'John Smith', age: 30, hobby: 'Coding', score: 1000, }); }); -test('should transform data in parallel', async t => { +void test('should transform data in parallel', async () => { const pipeline = parallel(addAge, getUser); const result = await pipeline({name: 'Jane Smith'}); - t.deepEqual(result, [{name: 'Jane Smith', age: 30}, {name: 'John Smith'}]); + assert.deepEqual(result, [{name: 'Jane Smith', age: 30}, {name: 'John Smith'}]); }); -test('should transform data in a parallel pipeline', async t => { +void test('should transform data in a parallel pipeline', async () => { const pipeline = pipe(getUser, parallel(addAge, addHobby)); const result = await pipeline(_); - t.deepEqual(result, [ + assert.deepEqual(result, [ {name: 'John Smith', age: 30}, {name: 'John Smith', hobby: 'Coding'}, ]); }); -test('should transform data in a compound parallel pipeline', async t => { +void test('should transform data in a compound parallel pipeline', async () => { const addAgeAndHobby = pipe(addAge, addHobby); const pipeline = pipe(getUser, parallel(addAgeAndHobby, addAgeAndHobby)); const result = await pipeline(_); - t.deepEqual(result, [ + assert.deepEqual(result, [ {name: 'John Smith', hobby: 'Coding', age: 30}, {name: 'John Smith', hobby: 'Coding', age: 30}, ]); }); -test('should assign the return of parallel', async t => { +void test('should assign the return of parallel', async () => { const pipeline = assign(parallel(addAge, addHobby)); const result = await pipeline({name: 'John Smith'}); - t.deepEqual(result, {name: 'John Smith', age: 30, hobby: 'Coding'}); + assert.deepEqual(result, {name: 'John Smith', age: 30, hobby: 'Coding'}); }); -test('should passthought the transformed data', async t => { - const pipeline = passthrough(() => t.pass()); +void test('should passthought the transformed data', async () => { + let captured; + const pipeline = passthrough(input => { + captured = input; + }); const result = await pipeline({name: 'John Smith'}); - t.deepEqual(result, {name: 'John Smith'}); - t.plan(2); + assert.deepEqual(captured, {name: 'John Smith'}); + assert.deepEqual(result, {name: 'John Smith'}); });