From f187f92166ed43d1b2c76ec99cc9727d1abddb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 6 Sep 2023 14:39:35 +0200 Subject: [PATCH 1/4] flake gonna flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 982ea36e..6a9b5c44 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1692793255, - "narHash": "sha256-yVyj0AE280JkccDHuG1XO9oGxN6bW8ksr/xttXcXzK0=", + "lastModified": 1693833206, + "narHash": "sha256-wHOY0nnD6gWj8u9uI85/YlsganYyWRK1hLFZulZwfmY=", "owner": "numtide", "repo": "devshell", - "rev": "2aa26972b951bc05c3632d4e5ae683cb6771a7c6", + "rev": "65114ea495a8d3cc1352368bf170d67ef005aa5a", "type": "github" }, "original": { From 49bcf7711f4c7e9339b021f409779dc3a8c11ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 6 Sep 2023 14:41:11 +0200 Subject: [PATCH 2/4] set up testing infrastructure for wallet package --- jest.config.js | 5 +++-- packages/wallet/package.json | 6 +++--- packages/wallet/test/jest.unit.config.mjs | 14 ++++++++++++++ packages/wallet/test/tsconfig.json | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 packages/wallet/test/jest.unit.config.mjs create mode 100644 packages/wallet/test/tsconfig.json diff --git a/jest.config.js b/jest.config.js index 56429a54..eaf944f8 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ module.exports = { testEnvironment: "node", projects: [ - '/packages/language/core/v1/test/jest.unit.config.mjs' - ] + "/packages/language/core/v1/test/jest.unit.config.mjs", + "/packages/wallet/test/jest.unit.config.mjs", + ], }; diff --git a/packages/wallet/package.json b/packages/wallet/package.json index 0ec5fb6b..2a89fc17 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -15,7 +15,7 @@ "scripts": { "build": "tsc --build src", "clean": "tsc --build --clean src", - "test": "echo 'wallet doesnt have tests for the moment'" + "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --config test/jest.unit.config.mjs" }, "type": "module", "module": "./dist/browser/index.js", @@ -42,7 +42,7 @@ "fp-ts": "^2.16.0", "io-ts": "2.2.20", "newtype-ts": "0.3.5", - "@47ng/codec" : "1.1.0", + "@47ng/codec": "1.1.0", "lucid-cardano": "0.9.4" } -} \ No newline at end of file +} diff --git a/packages/wallet/test/jest.unit.config.mjs b/packages/wallet/test/jest.unit.config.mjs new file mode 100644 index 00000000..a7878ff2 --- /dev/null +++ b/packages/wallet/test/jest.unit.config.mjs @@ -0,0 +1,14 @@ +const config = { + testEnvironment: "node", + displayName: "wallet", + extensionsToTreatAsEsm: [".ts"], + + moduleNameMapper: { + "^(\\.{1,2}/.*)\\.js$": "$1", + }, + transform: { + "^.+\\.ts$": ["ts-jest", { useESM: true }], + }, +}; + +export default config; diff --git a/packages/wallet/test/tsconfig.json b/packages/wallet/test/tsconfig.json new file mode 100644 index 00000000..08cc6b0f --- /dev/null +++ b/packages/wallet/test/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig-base.json", + "compilerOptions": { + "outDir": "../test-dist", + "paths": { + "@marlowe.io/adapter/*": ["../../adapter/src/*"], + "@marlowe.io/language-core-v1/*": ["../../language/core/v1/src*"], + "@marlowe.io/wallet/*": ["../src*"] + }, + "types": ["node", "jest"] + }, + "references": [ + { "path": "../../adapter/src" }, + { "path": "../../language/core/v1/src" }, + { "path": "../src" } + ] +} From 8f33e74ece4f7742f9ad755056380529ba0702b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 6 Sep 2023 14:44:58 +0200 Subject: [PATCH 3/4] convenience task for vs code users --- .vscode/tasks.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..e4e40f79 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build", + "group": "build", + "problemMatcher": [], + "label": "npm build", + "detail": "run build" + }, + { + "type": "npm", + "script": "test", + "group": "test", + "problemMatcher": [], + "label": "npm test", + "detail": "run test suite", + "dependsOn": "npm build" + } + ] +} From 28c287ef32930269c6580a0f79af3d27b27e3953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 6 Sep 2023 14:45:22 +0200 Subject: [PATCH 4/4] test example --- packages/wallet/src/nodejs/index.ts | 2 ++ packages/wallet/test/wallet.spec.ts | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 packages/wallet/test/wallet.spec.ts diff --git a/packages/wallet/src/nodejs/index.ts b/packages/wallet/src/nodejs/index.ts index 09e217fc..91218483 100644 --- a/packages/wallet/src/nodejs/index.ts +++ b/packages/wallet/src/nodejs/index.ts @@ -12,6 +12,8 @@ import * as Codec from '@47ng/codec' const log = (message:string) => console.log(`\t## - ${message}`); +export const foo = 42; + export type PrivateKeysAsHex = string export type Address = string; diff --git a/packages/wallet/test/wallet.spec.ts b/packages/wallet/test/wallet.spec.ts new file mode 100644 index 00000000..a01d4988 --- /dev/null +++ b/packages/wallet/test/wallet.spec.ts @@ -0,0 +1,7 @@ +import { foo } from "@marlowe.io/wallet/nodejs"; + +describe("wallet", () => { + it("succeeds", () => { + expect(foo).toStrictEqual(42); + }); +});