Skip to content

Commit

Permalink
Merge pull request #24 from input-output-hk/PLT-7441-setup-unit-testi…
Browse files Browse the repository at this point in the history
…ng-for-wallet-package

PLT-7441: Setup unit testing for wallet package
  • Loading branch information
bjornkihlberg authored Sep 6, 2023
2 parents a2922f8 + 28c287e commit 7d7f5f5
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
testEnvironment: "node",
projects: [
'<rootDir>/packages/language/core/v1/test/jest.unit.config.mjs'
]
"<rootDir>/packages/language/core/v1/test/jest.unit.config.mjs",
"<rootDir>/packages/wallet/test/jest.unit.config.mjs",
],
};
6 changes: 3 additions & 3 deletions packages/wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
}
2 changes: 2 additions & 0 deletions packages/wallet/src/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 14 additions & 0 deletions packages/wallet/test/jest.unit.config.mjs
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 17 additions & 0 deletions packages/wallet/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
7 changes: 7 additions & 0 deletions packages/wallet/test/wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { foo } from "@marlowe.io/wallet/nodejs";

describe("wallet", () => {
it("succeeds", () => {
expect(foo).toStrictEqual(42);
});
});

0 comments on commit 7d7f5f5

Please sign in to comment.