diff --git a/.github/workflows/test-node.yml b/.github/workflows/test-node.yml new file mode 100644 index 0000000..6be0cac --- /dev/null +++ b/.github/workflows/test-node.yml @@ -0,0 +1,27 @@ +name: Test (Node) + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22.x + - name: Install deps + run: | + npx jsr install + - name: Test + run: | + npx --yes tsx --test *_test.ts + npx --yes tsx --test async/*_test.ts + npx --yes tsx --test pipe/*_test.ts + npx --yes tsx --test pipe/async/*_test.ts + timeout-minutes: 5 diff --git a/.gitignore b/.gitignore index 4e4b189..eabbba7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /docs deno.lock .coverage +node_modules diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..41583e3 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@jsr:registry=https://npm.jsr.io diff --git a/deno.jsonc b/deno.jsonc index fe30d7c..973b122 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -21,6 +21,7 @@ }, "imports": { "@core/pipe": "./mod.ts", + "@cross/test": "jsr:@cross/test@^0.0.9", "@std/assert": "jsr:@std/assert@^1.0.2", "@std/jsonc": "jsr:@std/jsonc@^1.0.0", "@std/path": "jsr:@std/path@^1.0.2", diff --git a/mod_test.ts b/mod_test.ts index 25ee95a..339cf83 100644 --- a/mod_test.ts +++ b/mod_test.ts @@ -1,151 +1,140 @@ +import { test } from "@cross/test"; import { assertEquals } from "@std/assert"; import { assertType, type IsExact } from "@std/testing/types"; import { pipe } from "./mod.ts"; -Deno.test("pipe", async (t) => { - await t.step("with no operators", async (t) => { - await t.step("should return the input", () => { - assertEquals(pipe(1), 1); - }); - }); +await test("pipe with no operators should return the input", () => { + assertEquals(pipe(1), 1); +}); - await t.step("with one operator", async (t) => { - await t.step("should return operator applied value", () => { - assertEquals(pipe(1, (v) => v * 2), 2); - }); +await test("pipe with one operator should return operator applied value", () => { + assertEquals(pipe(1, (v) => v * 2), 2); +}); - await t.step("should resolve the type properly", () => { - pipe(1, (v) => { - assertType>(true); - return v.toString(); - }); - }); +await test("pipe with one operator should resolve the type properly", () => { + pipe(1, (v) => { + assertType>(true); + return v.toString(); }); +}); - await t.step("with two operators", async (t) => { - await t.step("should return operator applied value", () => { - assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4); - }); +await test("pipe with two operators should return operator applied value", () => { + assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4); +}); - await t.step("should resolve the type properly", () => { - pipe(1, (v) => { - assertType>(true); - return v.toString(); - }, (v) => { - assertType>(true); - return v.length; - }); - }); +await test("pipe with two operators should resolve the type properly", () => { + pipe(1, (v) => { + assertType>(true); + return v.toString(); + }, (v) => { + assertType>(true); + return v.length; }); +}); - await t.step("with three operators", async (t) => { - await t.step("should return operator applied value", () => { - assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8); - }); +await test("pipe with three operators should return operator applied value", () => { + assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8); +}); - await t.step("should resolve the type properly", () => { - pipe(1, (v) => { - assertType>(true); - return v.toString(); - }, (v) => { - assertType>(true); - return v.length; - }, (v) => { - assertType>(true); - return v.toString(); - }); - }); +await test("pipe with three operators should resolve the type properly", () => { + pipe(1, (v) => { + assertType>(true); + return v.toString(); + }, (v) => { + assertType>(true); + return v.length; + }, (v) => { + assertType>(true); + return v.toString(); }); +}); - await t.step(`with twenty operators`, async (t) => { - await t.step("should return operator applied value", () => { - assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20); - }); +await test("pipe with twenty operators should return operator applied value", () => { + assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20); +}); - await t.step("should resolve the type properly", () => { - pipe( - 1, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - (v) => { - assertType>(true); - return v; - }, - ); - }); - }); +await test("pipe with twenty operators should resolve the type properly", () => { + pipe( + 1, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + (v) => { + assertType>(true); + return v; + }, + ); }); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..19a54a0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,87 @@ +{ + "name": "pipe", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@cross/test": "npm:@jsr/cross__test@^0.0.9", + "@std/assert": "npm:@jsr/std__assert@^1.0.2", + "@std/testing": "npm:@jsr/std__testing@^1.0.0-rc.5" + } + }, + "node_modules/@cross/test": { + "name": "@jsr/cross__test", + "version": "0.0.9", + "resolved": "https://npm.jsr.io/~/11/@jsr/cross__test/0.0.9.tgz", + "integrity": "sha512-zwDSXQHw8n6k/gBj1Q67Td34Lb1PfkzLTggXnNZzcRO9SxcdAlzyOKFCF62kTFM7ZjVPqYvqu2gHzMLtj6cayw==", + "dependencies": { + "@jsr/cross__runtime": "^1.0.0" + } + }, + "node_modules/@jsr/cross__runtime": { + "version": "1.0.0", + "resolved": "https://npm.jsr.io/~/11/@jsr/cross__runtime/1.0.0.tgz", + "integrity": "sha512-wUtjVBTk65ae4AKQRnxD5x3h4vVmopdKAYie/uS01Qolii2XQ81bKtRTvJ4kx133GYYgIAgyl3ihQ0OK8LcPmQ==" + }, + "node_modules/@jsr/std__assert": { + "version": "1.0.2", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__assert/1.0.2.tgz", + "integrity": "sha512-xujHXXeT3zvMNZeCXiDyfiITaqP4rgH8wqHNUD0Iyr4c2R0Ea//zJ4pASA1utIEIxeVu1jpeSlHU4+pagscqgQ==", + "dependencies": { + "@jsr/std__internal": "^1.0.1" + } + }, + "node_modules/@jsr/std__async": { + "version": "1.0.3", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__async/1.0.3.tgz", + "integrity": "sha512-j5NZqYHN/czhfjBKh0jvPU5IRhP3Y5Lk7X3qL5ghw0gDSwI8h/kzlxSMV98ML0L6tXN9SvZU8lqa8Q5evtL4sA==" + }, + "node_modules/@jsr/std__data-structures": { + "version": "1.0.1", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__data-structures/1.0.1.tgz", + "integrity": "sha512-rxVsLaPwJEZNqVAfvOSfVw9WKgLwzUgwUIs7aMjKogGSPBSJkwXED6a3zL4eIrXQR+HR3+E0/Y10XYifu0gHkw==" + }, + "node_modules/@jsr/std__fs": { + "version": "1.0.1", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__fs/1.0.1.tgz", + "integrity": "sha512-QXNJz3X3IBYhxC1KEhtNPCUrtS8bofqxlVVN8ONrWXm0V9LbaJKJzsKsH3Z2KvdDmdHF3u+sNjRpafbJkOYedg==", + "dependencies": { + "@jsr/std__path": "^1.0.2" + } + }, + "node_modules/@jsr/std__internal": { + "version": "1.0.1", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__internal/1.0.1.tgz", + "integrity": "sha512-ssI1kvluIero6cCfiWNmYItqCR8QpQB+STBJoe/xQVZ79SDpoqjK5VF2Eq/2M+Dz8WbqHVmrXRCaGN162x+Ebw==" + }, + "node_modules/@jsr/std__path": { + "version": "1.0.2", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__path/1.0.2.tgz", + "integrity": "sha512-VadQVUlJZhIjRi8RcDQcNzqKcowfEdqntIXhphae0MeHaC1y60OiFealO25WTzBTHqBC58KFNlM7KWH+tepgOg==" + }, + "node_modules/@std/assert": { + "name": "@jsr/std__assert", + "version": "1.0.2", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__assert/1.0.2.tgz", + "integrity": "sha512-xujHXXeT3zvMNZeCXiDyfiITaqP4rgH8wqHNUD0Iyr4c2R0Ea//zJ4pASA1utIEIxeVu1jpeSlHU4+pagscqgQ==", + "dependencies": { + "@jsr/std__internal": "^1.0.1" + } + }, + "node_modules/@std/testing": { + "name": "@jsr/std__testing", + "version": "1.0.0-rc.5", + "resolved": "https://npm.jsr.io/~/11/@jsr/std__testing/1.0.0-rc.5.tgz", + "integrity": "sha512-p4Fa2fFk3qS9VMkpCCTmo/Jgwz7h6+iXBPbDVSgy2lbAyBDGWVw8d4S0qx8i7O6TQkSgEHyB4bP9z8HYao7NyQ==", + "dependencies": { + "@jsr/std__assert": "^1.0.1", + "@jsr/std__async": "^1.0.1", + "@jsr/std__data-structures": "^1.0.1", + "@jsr/std__fs": "^1.0.0", + "@jsr/std__internal": "^1.0.1", + "@jsr/std__path": "^1.0.2" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..03bac82 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "type": "module", + "dependencies": { + "@cross/test": "npm:@jsr/cross__test@^0.0.9", + "@std/assert": "npm:@jsr/std__assert@^1.0.2", + "@std/testing": "npm:@jsr/std__testing@^1.0.0-rc.5" + } +}