-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jsr-core/add-tests
test: Add tests for Node
- Loading branch information
Showing
7 changed files
with
249 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/docs | ||
deno.lock | ||
.coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@jsr:registry=https://npm.jsr.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}); | ||
}); | ||
await test("pipe with one operator should resolve the type properly", () => { | ||
pipe(1, (v) => { | ||
assertType<IsExact<typeof v, number>>(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<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}, (v) => { | ||
assertType<IsExact<typeof v, string>>(true); | ||
return v.length; | ||
}); | ||
}); | ||
await test("pipe with two operators should resolve the type properly", () => { | ||
pipe(1, (v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}, (v) => { | ||
assertType<IsExact<typeof v, string>>(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<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}, (v) => { | ||
assertType<IsExact<typeof v, string>>(true); | ||
return v.length; | ||
}, (v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}); | ||
}); | ||
await test("pipe with three operators should resolve the type properly", () => { | ||
pipe(1, (v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v.toString(); | ||
}, (v) => { | ||
assertType<IsExact<typeof v, string>>(true); | ||
return v.length; | ||
}, (v) => { | ||
assertType<IsExact<typeof v, number>>(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<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
); | ||
}); | ||
}); | ||
await test("pipe with twenty operators should resolve the type properly", () => { | ||
pipe( | ||
1, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
(v) => { | ||
assertType<IsExact<typeof v, number>>(true); | ||
return v; | ||
}, | ||
); | ||
}); |
Oops, something went wrong.