Skip to content

Commit 9f14f8a

Browse files
authored
Modularize test suite (#34)
1 parent 77136da commit 9f14f8a

File tree

12 files changed

+233
-186
lines changed

12 files changed

+233
-186
lines changed

.changeset/itchy-bananas-punch.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"core-tests": patch
3+
"testsuite": patch
4+
"@guidanoli/cmioc": patch
5+
---
6+
7+
Modularize test suite

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
"private": true,
33
"scripts": {
44
"build": "run-s build:packages build:apps",
5-
"build:packages": "run-s build:core",
5+
"build:packages": "run-s build:core build:testsuite",
66
"build:apps": "run-p build:cli build:site",
77
"build:core": "pnpm run --filter @guidanoli/cmioc build",
88
"build:cli": "pnpm run --filter @guidanoli/cmioc-cli build",
99
"build:site": "pnpm run --filter site build",
10+
"build:testsuite": "pnpm run --filter testsuite build",
1011
"check-format": "prettier --check .",
1112
"format": "prettier --check --write .",
1213
"publish": "changeset publish",
1314
"release": "run-s build publish",
14-
"test": "run-s test:core",
15-
"test:core": "pnpm run --filter @guidanoli/cmioc test"
15+
"test": "run-s build:packages test:core",
16+
"test:core": "pnpm run --filter core-tests test"
1617
},
1718
"devDependencies": {
1819
"@changesets/cli": "^2.27.7",
File renamed without changes.

packages/core-tests/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "core-tests",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"test": "jest"
7+
},
8+
"dependencies": {
9+
"@guidanoli/cmioc": "workspace:*",
10+
"testsuite": "workspace:*"
11+
},
12+
"devDependencies": {
13+
"@jest/globals": "^29.7.0",
14+
"jest": "^29.7.0",
15+
"ts-jest": "^29.1.2",
16+
"tsconfig": "workspace:*"
17+
}
18+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, test } from "@jest/globals";
2+
3+
import {
4+
encodeInput,
5+
encodeOutput,
6+
decodeInput,
7+
decodeOutput,
8+
} from "@guidanoli/cmioc";
9+
import { inputTestSuite, outputTestSuite } from "testsuite";
10+
11+
for (const { name, blob, data: input } of inputTestSuite) {
12+
describe(name, () => {
13+
test("encode", () => {
14+
expect(encodeInput(input)).toEqual(blob);
15+
});
16+
test("decode", () => {
17+
expect(decodeInput(blob)).toEqual(input);
18+
});
19+
});
20+
}
21+
22+
for (const { name, blob, data: output } of outputTestSuite) {
23+
describe(name, () => {
24+
test("encode", () => {
25+
expect(encodeOutput(output)).toEqual(blob);
26+
});
27+
test("decode", () => {
28+
expect(decodeOutput(blob)).toEqual(output);
29+
});
30+
});
31+
}

packages/core-tests/tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "dist"
4+
},
5+
"extends": "tsconfig/base.json",
6+
"include": ["src"]
7+
}

packages/core/package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@
2626
"scripts": {
2727
"build": "tsc",
2828
"clean": "rimraf dist",
29-
"prepack": "run-s build",
30-
"test": "jest"
29+
"prepack": "run-s build"
3130
},
3231
"dependencies": {
3332
"@cartesi/rollups": "2.0.0-rc.3",
3433
"ethers": "^6.11.1",
3534
"viem": "^2.9.2"
3635
},
3736
"devDependencies": {
38-
"@jest/globals": "^29.7.0",
39-
"jest": "^29.7.0",
4037
"rimraf": "^5.0.5",
41-
"ts-jest": "^29.1.2",
4238
"tsconfig": "workspace:*",
4339
"typescript": "catalog:"
4440
}

packages/core/test/index.test.ts

-175
This file was deleted.

packages/testsuite/package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "testsuite",
3+
"version": "0.0.0",
4+
"private": true,
5+
"files": [
6+
"dist"
7+
],
8+
"main": "dist/src/index.js",
9+
"types": "dist/src/index.d.ts",
10+
"scripts": {
11+
"build": "tsc",
12+
"clean": "rimraf dist",
13+
"prepack": "run-s build"
14+
},
15+
"dependencies": {
16+
"@guidanoli/cmioc": "workspace:*",
17+
"viem": "^2.9.2"
18+
},
19+
"devDependencies": {
20+
"rimraf": "^5.0.5",
21+
"tsconfig": "workspace:*",
22+
"typescript": "catalog:"
23+
}
24+
}

0 commit comments

Comments
 (0)