Skip to content

Commit 13890e3

Browse files
authored
🩹 Fix hub test (#715)
1 parent a66626d commit 13890e3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

‎packages/hub/src/lib/who-am-i.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ describe("whoAmI", () => {
66
it("should fetch identity info", async () => {
77
const info = await whoAmI({ credentials: { accessToken: TEST_ACCESS_TOKEN }, hubUrl: TEST_HUB_URL });
88

9+
if (info.auth.accessToken?.createdAt instanceof Date) {
10+
info.auth.accessToken.createdAt = new Date(0);
11+
}
12+
913
assert.deepStrictEqual(info, {
1014
type: "user",
1115
id: "62f264b9f3c90f4b6514a269",
@@ -21,6 +25,7 @@ describe("whoAmI", () => {
2125
auth: {
2226
type: "access_token",
2327
accessToken: {
28+
createdAt: new Date(0),
2429
displayName: "ci-hub.js",
2530
role: "write",
2631
},

‎packages/hub/src/lib/who-am-i.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export interface AuthInfo {
5252
type: AuthType;
5353
accessToken?: {
5454
displayName: string;
55-
expiration?: Date;
5655
role: AccessTokenRole;
56+
createdAt: Date;
5757
};
5858
expiresAt?: Date;
5959
}
@@ -79,17 +79,11 @@ export async function whoAmI(params: {
7979
}
8080

8181
const response: ApiWhoAmIReponse & {
82-
auth: Omit<AuthInfo, "accessToken"> & {
83-
accessToken?: {
84-
displayName: string;
85-
expiration?: Date; // actually string but we fix it below
86-
role: AccessTokenRole;
87-
};
88-
};
82+
auth: AuthInfo;
8983
} = await res.json();
9084

91-
if (typeof response.auth.accessToken?.expiration === "string") {
92-
response.auth.accessToken.expiration = new Date(response.auth.accessToken.expiration);
85+
if (typeof response.auth.accessToken?.createdAt === "string") {
86+
response.auth.accessToken.createdAt = new Date(response.auth.accessToken.createdAt);
9387
}
9488

9589
return response;

0 commit comments

Comments
 (0)