-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into alert-refactor
- Loading branch information
Showing
34 changed files
with
609 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
bunx lint-staged --config package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { SessionData, transformSessionToAuth } from "./auth"; | ||
|
||
describe("Auth helpers", () => { | ||
describe("transformSessionToAuth", () => { | ||
it("correctly uses expire_in_seconds when transforming to local time", () => { | ||
const mockCurrentISODate = "2021-10-10T10:10:00.000Z"; | ||
|
||
// Note: Discrepancy between ISO dates and ends_in_seconds and expire_in_seconds | ||
// This is intentional to test that the function does infact use the seconds and not the time stamps. | ||
const mockSessionData: SessionData = { | ||
session: { | ||
created_at: "2021-10-10T10:00:00.000Z", | ||
ends_at: "2021-10-10T16:00:00.000Z", | ||
timeout_at: "2021-10-10T16:00:00.000Z", | ||
ends_in_seconds: 3600, | ||
active: true, | ||
timeout_in_seconds: 3600, | ||
}, | ||
tokens: { | ||
expire_at: "2021-10-10T11:05:00.000Z", | ||
refreshed_at: "2021-10-10T12:05:00.000Z", | ||
expire_in_seconds: 1800, | ||
next_auto_refresh_in_seconds: 1800, | ||
refresh_cooldown: false, | ||
refresh_cooldown_seconds: 0, | ||
}, | ||
}; | ||
|
||
vi.useFakeTimers(); | ||
vi.setSystemTime(mockCurrentISODate); | ||
|
||
const authData = transformSessionToAuth(mockSessionData); | ||
|
||
expect(authData.sessionExpireAtLocal).toBe( | ||
"2021-10-10T11:10:00.000Z", | ||
); | ||
expect(authData.tokenExpireAtLocal).toBe( | ||
"2021-10-10T10:40:00.000Z", | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.