Skip to content

Commit b260e70

Browse files
committed
test: add test to check the package exports valid functions of a certain type
1 parent 2967af5 commit b260e70

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
createKey,
3+
getKeys,
4+
isDeviceSupported,
5+
isPassKeyAvailable,
6+
} from "@near-js/biometric-ed25519";
7+
import { KeyPair } from "@near-js/crypto";
8+
import { expectTypeOf, test } from "vitest";
9+
10+
test(`exports "createKey" function with correct type`, async () => {
11+
type ExpectedFunction = (username: string) => Promise<KeyPair>;
12+
13+
expectTypeOf(createKey).toEqualTypeOf<ExpectedFunction>();
14+
});
15+
16+
test(`exports "getKeys" function with correct type`, async () => {
17+
type ExpectedFunction = (username: string) => Promise<[KeyPair, KeyPair]>;
18+
19+
expectTypeOf(getKeys).toEqualTypeOf<ExpectedFunction>();
20+
});
21+
22+
test(`exports "isDeviceSupported" function with correct type`, async () => {
23+
type ExpectedFunction = () => Promise<boolean>;
24+
25+
expectTypeOf(isDeviceSupported).toEqualTypeOf<ExpectedFunction>();
26+
});
27+
28+
test(`exports "isPassKeyAvailable" function with correct type`, async () => {
29+
type ExpectedFunction = () => Promise<boolean>;
30+
31+
expectTypeOf(isPassKeyAvailable).toEqualTypeOf<ExpectedFunction>();
32+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
createKey,
3+
getKeys,
4+
isDeviceSupported,
5+
isPassKeyAvailable,
6+
} from "@near-js/biometric-ed25519";
7+
import { expect, test } from "vitest";
8+
9+
test(`exports "createKey" function`, () => {
10+
expect(createKey).toBeDefined();
11+
});
12+
13+
test(`exports "getKeys" function`, () => {
14+
expect(getKeys).toBeDefined();
15+
});
16+
17+
test(`exports "isDeviceSupported" function`, () => {
18+
expect(isDeviceSupported).toBeDefined();
19+
});
20+
21+
test(`exports "isPassKeyAvailable" function`, () => {
22+
expect(isPassKeyAvailable).toBeDefined();
23+
});

0 commit comments

Comments
 (0)