Skip to content

Commit

Permalink
Modularize test suite (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli authored Jul 18, 2024
1 parent 77136da commit 9f14f8a
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 186 deletions.
7 changes: 7 additions & 0 deletions .changeset/itchy-bananas-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"core-tests": patch
"testsuite": patch
"@guidanoli/cmioc": patch
---

Modularize test suite
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
"private": true,
"scripts": {
"build": "run-s build:packages build:apps",
"build:packages": "run-s build:core",
"build:packages": "run-s build:core build:testsuite",
"build:apps": "run-p build:cli build:site",
"build:core": "pnpm run --filter @guidanoli/cmioc build",
"build:cli": "pnpm run --filter @guidanoli/cmioc-cli build",
"build:site": "pnpm run --filter site build",
"build:testsuite": "pnpm run --filter testsuite build",
"check-format": "prettier --check .",
"format": "prettier --check --write .",
"publish": "changeset publish",
"release": "run-s build publish",
"test": "run-s test:core",
"test:core": "pnpm run --filter @guidanoli/cmioc test"
"test": "run-s build:packages test:core",
"test:core": "pnpm run --filter core-tests test"
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions packages/core-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "core-tests",
"version": "0.0.0",
"private": true,
"scripts": {
"test": "jest"
},
"dependencies": {
"@guidanoli/cmioc": "workspace:*",
"testsuite": "workspace:*"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"tsconfig": "workspace:*"
}
}
31 changes: 31 additions & 0 deletions packages/core-tests/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { describe, expect, test } from "@jest/globals";

import {
encodeInput,
encodeOutput,
decodeInput,
decodeOutput,
} from "@guidanoli/cmioc";
import { inputTestSuite, outputTestSuite } from "testsuite";

for (const { name, blob, data: input } of inputTestSuite) {
describe(name, () => {
test("encode", () => {
expect(encodeInput(input)).toEqual(blob);
});
test("decode", () => {
expect(decodeInput(blob)).toEqual(input);
});
});
}

for (const { name, blob, data: output } of outputTestSuite) {
describe(name, () => {
test("encode", () => {
expect(encodeOutput(output)).toEqual(blob);
});
test("decode", () => {
expect(decodeOutput(blob)).toEqual(output);
});
});
}
7 changes: 7 additions & 0 deletions packages/core-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"outDir": "dist"
},
"extends": "tsconfig/base.json",
"include": ["src"]
}
6 changes: 1 addition & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@
"scripts": {
"build": "tsc",
"clean": "rimraf dist",
"prepack": "run-s build",
"test": "jest"
"prepack": "run-s build"
},
"dependencies": {
"@cartesi/rollups": "2.0.0-rc.3",
"ethers": "^6.11.1",
"viem": "^2.9.2"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"tsconfig": "workspace:*",
"typescript": "catalog:"
}
Expand Down
175 changes: 0 additions & 175 deletions packages/core/test/index.test.ts

This file was deleted.

24 changes: 24 additions & 0 deletions packages/testsuite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "testsuite",
"version": "0.0.0",
"private": true,
"files": [
"dist"
],
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"build": "tsc",
"clean": "rimraf dist",
"prepack": "run-s build"
},
"dependencies": {
"@guidanoli/cmioc": "workspace:*",
"viem": "^2.9.2"
},
"devDependencies": {
"rimraf": "^5.0.5",
"tsconfig": "workspace:*",
"typescript": "catalog:"
}
}
Loading

0 comments on commit 9f14f8a

Please sign in to comment.