Skip to content

Commit 46b4ed1

Browse files
committed
refactor: fix test
1 parent 7839e83 commit 46b4ed1

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

packages/capacitor/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('CapacitorLogtoClient', () => {
2323
it('should override navigate', async () => {
2424
const client = createClient();
2525
expect(client.getAdapter().navigate).toBeDefined();
26-
await client.getAdapter().navigate('https://example.com');
26+
await client.getAdapter().navigate('https://example.com', { for: 'sign-in' });
2727

2828
const spy = jest.spyOn(Browser, 'open');
2929
expect(spy).toHaveBeenCalledWith({

packages/client/jest.setup.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
// Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom
22
// https://github.com/jsdom/jsdom/issues/1612
3+
4+
import crypto from 'node:crypto';
5+
36
import { TextDecoder, TextEncoder } from 'text-encoder';
47

58
/* eslint-disable @silverhand/fp/no-mutation */
69
global.TextDecoder = TextDecoder;
710
global.TextEncoder = TextEncoder;
11+
12+
// Mock WebCrypto in JSDOM
13+
if (global.window !== undefined) {
14+
global.CryptoKey = crypto.webcrypto.CryptoKey;
15+
global.crypto.subtle = crypto.webcrypto.subtle;
16+
}
817
/* eslint-enable @silverhand/fp/no-mutation */

packages/client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"build": "rm -rf lib/ && tsc -p tsconfig.build.json --noEmit && rollup -c",
3636
"lint": "eslint --ext .ts src",
3737
"test": "jest",
38+
"test:jsdom": "jest --env=jsdom",
3839
"test:coverage": "jest --silent --env=jsdom && jest --silent --coverage",
3940
"prepack": "pnpm build && pnpm test"
4041
},

packages/js/jest.setup.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
// Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom
22
// https://github.com/jsdom/jsdom/issues/1612
33

4-
import crypto from 'node:crypto';
5-
64
import { TextDecoder, TextEncoder } from 'text-encoder';
75

86
/* eslint-disable @silverhand/fp/no-mutation */
9-
// Mock WebCrypto in JSDOM
10-
if (global.window !== undefined) {
11-
global.CryptoKey = crypto.webcrypto.CryptoKey;
12-
global.crypto.subtle = crypto.webcrypto.subtle;
13-
}
14-
157
global.TextDecoder = TextDecoder;
168
global.TextEncoder = TextEncoder;
179
/* eslint-enable @silverhand/fp/no-mutation */

0 commit comments

Comments
 (0)