Skip to content

Commit f6f3a75

Browse files
authored
Merge pull request #2 from jsr-core/add-tests
test: Add tests for Node
2 parents 579f7fb + c90f6d7 commit f6f3a75

File tree

7 files changed

+249
-135
lines changed

7 files changed

+249
-135
lines changed

.github/workflows/test-node.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test (Node)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 22.x
18+
- name: Install deps
19+
run: |
20+
npx jsr install
21+
- name: Test
22+
run: |
23+
npx --yes tsx --test *_test.ts
24+
npx --yes tsx --test async/*_test.ts
25+
npx --yes tsx --test pipe/*_test.ts
26+
npx --yes tsx --test pipe/async/*_test.ts
27+
timeout-minutes: 5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/docs
22
deno.lock
33
.coverage
4+
node_modules

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@jsr:registry=https://npm.jsr.io

deno.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"imports": {
2323
"@core/pipe": "./mod.ts",
24+
"@cross/test": "jsr:@cross/test@^0.0.9",
2425
"@std/assert": "jsr:@std/assert@^1.0.2",
2526
"@std/jsonc": "jsr:@std/jsonc@^1.0.0",
2627
"@std/path": "jsr:@std/path@^1.0.2",

mod_test.ts

Lines changed: 124 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,140 @@
1+
import { test } from "@cross/test";
12
import { assertEquals } from "@std/assert";
23
import { assertType, type IsExact } from "@std/testing/types";
34
import { pipe } from "./mod.ts";
45

5-
Deno.test("pipe", async (t) => {
6-
await t.step("with no operators", async (t) => {
7-
await t.step("should return the input", () => {
8-
assertEquals(pipe(1), 1);
9-
});
10-
});
6+
await test("pipe with no operators should return the input", () => {
7+
assertEquals(pipe(1), 1);
8+
});
119

12-
await t.step("with one operator", async (t) => {
13-
await t.step("should return operator applied value", () => {
14-
assertEquals(pipe(1, (v) => v * 2), 2);
15-
});
10+
await test("pipe with one operator should return operator applied value", () => {
11+
assertEquals(pipe(1, (v) => v * 2), 2);
12+
});
1613

17-
await t.step("should resolve the type properly", () => {
18-
pipe(1, (v) => {
19-
assertType<IsExact<typeof v, number>>(true);
20-
return v.toString();
21-
});
22-
});
14+
await test("pipe with one operator should resolve the type properly", () => {
15+
pipe(1, (v) => {
16+
assertType<IsExact<typeof v, number>>(true);
17+
return v.toString();
2318
});
19+
});
2420

25-
await t.step("with two operators", async (t) => {
26-
await t.step("should return operator applied value", () => {
27-
assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4);
28-
});
21+
await test("pipe with two operators should return operator applied value", () => {
22+
assertEquals(pipe(1, (v) => v * 2, (v) => v * 2), 4);
23+
});
2924

30-
await t.step("should resolve the type properly", () => {
31-
pipe(1, (v) => {
32-
assertType<IsExact<typeof v, number>>(true);
33-
return v.toString();
34-
}, (v) => {
35-
assertType<IsExact<typeof v, string>>(true);
36-
return v.length;
37-
});
38-
});
25+
await test("pipe with two operators should resolve the type properly", () => {
26+
pipe(1, (v) => {
27+
assertType<IsExact<typeof v, number>>(true);
28+
return v.toString();
29+
}, (v) => {
30+
assertType<IsExact<typeof v, string>>(true);
31+
return v.length;
3932
});
33+
});
4034

41-
await t.step("with three operators", async (t) => {
42-
await t.step("should return operator applied value", () => {
43-
assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8);
44-
});
35+
await test("pipe with three operators should return operator applied value", () => {
36+
assertEquals(pipe(1, (v) => v * 2, (v) => v * 2, (v) => v * 2), 8);
37+
});
4538

46-
await t.step("should resolve the type properly", () => {
47-
pipe(1, (v) => {
48-
assertType<IsExact<typeof v, number>>(true);
49-
return v.toString();
50-
}, (v) => {
51-
assertType<IsExact<typeof v, string>>(true);
52-
return v.length;
53-
}, (v) => {
54-
assertType<IsExact<typeof v, number>>(true);
55-
return v.toString();
56-
});
57-
});
39+
await test("pipe with three operators should resolve the type properly", () => {
40+
pipe(1, (v) => {
41+
assertType<IsExact<typeof v, number>>(true);
42+
return v.toString();
43+
}, (v) => {
44+
assertType<IsExact<typeof v, string>>(true);
45+
return v.length;
46+
}, (v) => {
47+
assertType<IsExact<typeof v, number>>(true);
48+
return v.toString();
5849
});
50+
});
5951

60-
await t.step(`with twenty operators`, async (t) => {
61-
await t.step("should return operator applied value", () => {
62-
assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20);
63-
});
52+
await test("pipe with twenty operators should return operator applied value", () => {
53+
assertEquals(pipe(1, ...Array(20).fill((v: number) => v * 2)), 2 ** 20);
54+
});
6455

65-
await t.step("should resolve the type properly", () => {
66-
pipe(
67-
1,
68-
(v) => {
69-
assertType<IsExact<typeof v, number>>(true);
70-
return v;
71-
},
72-
(v) => {
73-
assertType<IsExact<typeof v, number>>(true);
74-
return v;
75-
},
76-
(v) => {
77-
assertType<IsExact<typeof v, number>>(true);
78-
return v;
79-
},
80-
(v) => {
81-
assertType<IsExact<typeof v, number>>(true);
82-
return v;
83-
},
84-
(v) => {
85-
assertType<IsExact<typeof v, number>>(true);
86-
return v;
87-
},
88-
(v) => {
89-
assertType<IsExact<typeof v, number>>(true);
90-
return v;
91-
},
92-
(v) => {
93-
assertType<IsExact<typeof v, number>>(true);
94-
return v;
95-
},
96-
(v) => {
97-
assertType<IsExact<typeof v, number>>(true);
98-
return v;
99-
},
100-
(v) => {
101-
assertType<IsExact<typeof v, number>>(true);
102-
return v;
103-
},
104-
(v) => {
105-
assertType<IsExact<typeof v, number>>(true);
106-
return v;
107-
},
108-
(v) => {
109-
assertType<IsExact<typeof v, number>>(true);
110-
return v;
111-
},
112-
(v) => {
113-
assertType<IsExact<typeof v, number>>(true);
114-
return v;
115-
},
116-
(v) => {
117-
assertType<IsExact<typeof v, number>>(true);
118-
return v;
119-
},
120-
(v) => {
121-
assertType<IsExact<typeof v, number>>(true);
122-
return v;
123-
},
124-
(v) => {
125-
assertType<IsExact<typeof v, number>>(true);
126-
return v;
127-
},
128-
(v) => {
129-
assertType<IsExact<typeof v, number>>(true);
130-
return v;
131-
},
132-
(v) => {
133-
assertType<IsExact<typeof v, number>>(true);
134-
return v;
135-
},
136-
(v) => {
137-
assertType<IsExact<typeof v, number>>(true);
138-
return v;
139-
},
140-
(v) => {
141-
assertType<IsExact<typeof v, number>>(true);
142-
return v;
143-
},
144-
(v) => {
145-
assertType<IsExact<typeof v, number>>(true);
146-
return v;
147-
},
148-
);
149-
});
150-
});
56+
await test("pipe with twenty operators should resolve the type properly", () => {
57+
pipe(
58+
1,
59+
(v) => {
60+
assertType<IsExact<typeof v, number>>(true);
61+
return v;
62+
},
63+
(v) => {
64+
assertType<IsExact<typeof v, number>>(true);
65+
return v;
66+
},
67+
(v) => {
68+
assertType<IsExact<typeof v, number>>(true);
69+
return v;
70+
},
71+
(v) => {
72+
assertType<IsExact<typeof v, number>>(true);
73+
return v;
74+
},
75+
(v) => {
76+
assertType<IsExact<typeof v, number>>(true);
77+
return v;
78+
},
79+
(v) => {
80+
assertType<IsExact<typeof v, number>>(true);
81+
return v;
82+
},
83+
(v) => {
84+
assertType<IsExact<typeof v, number>>(true);
85+
return v;
86+
},
87+
(v) => {
88+
assertType<IsExact<typeof v, number>>(true);
89+
return v;
90+
},
91+
(v) => {
92+
assertType<IsExact<typeof v, number>>(true);
93+
return v;
94+
},
95+
(v) => {
96+
assertType<IsExact<typeof v, number>>(true);
97+
return v;
98+
},
99+
(v) => {
100+
assertType<IsExact<typeof v, number>>(true);
101+
return v;
102+
},
103+
(v) => {
104+
assertType<IsExact<typeof v, number>>(true);
105+
return v;
106+
},
107+
(v) => {
108+
assertType<IsExact<typeof v, number>>(true);
109+
return v;
110+
},
111+
(v) => {
112+
assertType<IsExact<typeof v, number>>(true);
113+
return v;
114+
},
115+
(v) => {
116+
assertType<IsExact<typeof v, number>>(true);
117+
return v;
118+
},
119+
(v) => {
120+
assertType<IsExact<typeof v, number>>(true);
121+
return v;
122+
},
123+
(v) => {
124+
assertType<IsExact<typeof v, number>>(true);
125+
return v;
126+
},
127+
(v) => {
128+
assertType<IsExact<typeof v, number>>(true);
129+
return v;
130+
},
131+
(v) => {
132+
assertType<IsExact<typeof v, number>>(true);
133+
return v;
134+
},
135+
(v) => {
136+
assertType<IsExact<typeof v, number>>(true);
137+
return v;
138+
},
139+
);
151140
});

0 commit comments

Comments
 (0)