forked from Dshield-xyz/Dshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkyc.test.ts
More file actions
47 lines (41 loc) · 1.21 KB
/
Copy pathkyc.test.ts
File metadata and controls
47 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { describe, it, expect } from "vitest";
import { saveKyc, getKyc, clearKyc, type KycRecord } from "./kyc";
function makeKyc(overrides: Partial<KycRecord> = {}): KycRecord {
return {
preimage: "00aabbcc",
hash: "ddeeff00",
registeredOnChain: true,
createdAt: Date.now(),
...overrides,
};
}
describe("saveKyc / getKyc", () => {
it("returns null when nothing saved", () => {
expect(getKyc()).toBeNull();
});
it("saves and retrieves a KYC record", () => {
const kyc = makeKyc();
saveKyc(kyc);
const retrieved = getKyc();
expect(retrieved).not.toBeNull();
expect(retrieved!.preimage).toBe("00aabbcc");
expect(retrieved!.hash).toBe("ddeeff00");
expect(retrieved!.registeredOnChain).toBe(true);
});
it("overwrites previous KYC record", () => {
saveKyc(makeKyc({ hash: "first" }));
saveKyc(makeKyc({ hash: "second" }));
expect(getKyc()!.hash).toBe("second");
});
});
describe("clearKyc", () => {
it("removes stored KYC data", () => {
saveKyc(makeKyc());
expect(getKyc()).not.toBeNull();
clearKyc();
expect(getKyc()).toBeNull();
});
it("does not throw when nothing to clear", () => {
expect(() => clearKyc()).not.toThrow();
});
});