From 87b0bdfb7e90508e5de685a0f193c44a2526c39c Mon Sep 17 00:00:00 2001 From: Marin Petrunic Date: Wed, 24 Jan 2024 12:02:54 +0100 Subject: [PATCH] chore: changed tests to run on happy-dom Signed-off-by: Marin Petrunic --- packages/widget/package.json | 1 + .../address-input/address-input.test.ts | 4 +--- packages/widget/vite.config.ts | 2 +- yarn.lock | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/widget/package.json b/packages/widget/package.json index 19cae73a..ab5c9a0e 100644 --- a/packages/widget/package.json +++ b/packages/widget/package.json @@ -46,6 +46,7 @@ "@open-wc/testing-helpers": "^3.0.0", "eslint": "^8.48.0", "eslint-plugin-lit": "^1.9.1", + "happy-dom": "^13.3.1", "jsdom": "^23.2.0", "lit-analyzer": "^2.0.3", "rollup-plugin-visualizer": "^5.9.2", diff --git a/packages/widget/tests/unit/components/address-input/address-input.test.ts b/packages/widget/tests/unit/components/address-input/address-input.test.ts index 5fcc4a3f..de6ba138 100644 --- a/packages/widget/tests/unit/components/address-input/address-input.test.ts +++ b/packages/widget/tests/unit/components/address-input/address-input.test.ts @@ -59,9 +59,7 @@ describe('address-input component', function () { ]); }); - // NOTE: this is not passing due to decodeAddress call failing in validateSubstrateAddress - // it seems checksum fails when running this on jsdom env - it.skip('triggers callback on address change and validates Substrate address', async () => { + it('triggers callback on address change and validates Substrate address', async () => { const mockAddressChangeHandler = vi.fn(); const el = await fixture(html` diff --git a/packages/widget/vite.config.ts b/packages/widget/vite.config.ts index bea954fd..0cac4a3b 100644 --- a/packages/widget/vite.config.ts +++ b/packages/widget/vite.config.ts @@ -17,7 +17,7 @@ export default defineConfig({ }, }, test: { - environment: 'jsdom', + environment: 'happy-dom', include: ['**/*.test.ts'], exclude: ['**/node_modules/**', '**/dist/**', '**/build/**'] } diff --git a/yarn.lock b/yarn.lock index 570eb18d..c249a456 100644 --- a/yarn.lock +++ b/yarn.lock @@ -256,6 +256,7 @@ __metadata: eslint-plugin-lit: "npm:^1.9.1" ethers: "npm:5.7.2" events: "npm:^3.3.0" + happy-dom: "npm:^13.3.1" jsdom: "npm:^23.2.0" lit: "npm:3.0.0" lit-analyzer: "npm:^2.0.3" @@ -7263,6 +7264,17 @@ __metadata: languageName: node linkType: hard +"happy-dom@npm:^13.3.1": + version: 13.3.1 + resolution: "happy-dom@npm:13.3.1" + dependencies: + entities: "npm:^4.5.0" + webidl-conversions: "npm:^7.0.0" + whatwg-mimetype: "npm:^3.0.0" + checksum: e9605d17f1d5219c4fab325614c65fd8c01f244d1b0ff7714cec679fb1d00e9af74e458871999bd1fb202d84b57d6f90798358c08b2ee48fcf0a7cb406678993 + languageName: node + linkType: hard + "har-schema@npm:^2.0.0": version: 2.0.0 resolution: "har-schema@npm:2.0.0" @@ -12389,6 +12401,13 @@ __metadata: languageName: node linkType: hard +"whatwg-mimetype@npm:^3.0.0": + version: 3.0.0 + resolution: "whatwg-mimetype@npm:3.0.0" + checksum: 323895a1cda29a5fb0b9ca82831d2c316309fede0365047c4c323073e3239067a304a09a1f4b123b9532641ab604203f33a1403b5ca6a62ef405bcd7a204080f + languageName: node + linkType: hard + "whatwg-mimetype@npm:^4.0.0": version: 4.0.0 resolution: "whatwg-mimetype@npm:4.0.0"