-
Notifications
You must be signed in to change notification settings - Fork 454
Expand file tree
/
Copy pathuser.test.ts
More file actions
39 lines (34 loc) · 986 Bytes
/
user.test.ts
File metadata and controls
39 lines (34 loc) · 986 Bytes
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
import { describe, expect, it } from "vitest";
import { filterClaims } from "./user.js";
describe("filterClaims", async () => {
it("should return only the allowed claims", () => {
const claims = {
sub: "user_123",
name: "John Doe",
nickname: "johndoe",
given_name: "John",
family_name: "Doe",
picture: "https://example.com/johndoe.jpg",
email: "john@example.com",
email_verified: true,
org_id: "org_123",
// Extra claims
iat: 1234567890,
exp: 1234567890
};
expect(filterClaims(claims)).toEqual({
sub: "user_123",
name: "John Doe",
nickname: "johndoe",
given_name: "John",
family_name: "Doe",
picture: "https://example.com/johndoe.jpg",
email: "john@example.com",
email_verified: true,
org_id: "org_123"
});
});
it("should return an empty object if no claims are provided", () => {
expect(filterClaims({})).toEqual({});
});
});