feat: add logto auth and backend metrics integration
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
|
||||
import { createAuthController } from "../src/background/auth/controller";
|
||||
|
||||
describe("background-auth-controller", () => {
|
||||
test("returns unauthenticated state when the client is logged out", async () => {
|
||||
const controller = createAuthController({
|
||||
authClient: {
|
||||
getAccessToken: vi.fn(),
|
||||
getIdTokenClaims: vi.fn(),
|
||||
isAuthenticated: vi.fn(async () => false),
|
||||
signIn: vi.fn(),
|
||||
signOut: vi.fn()
|
||||
}
|
||||
});
|
||||
|
||||
await expect(controller.getAuthState()).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
isAuthenticated: false
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("delegates sign in to the auth client", async () => {
|
||||
const signIn = vi.fn(async () => undefined);
|
||||
const controller = createAuthController({
|
||||
authClient: {
|
||||
getAccessToken: vi.fn(),
|
||||
getIdTokenClaims: vi.fn(),
|
||||
isAuthenticated: vi.fn(async () => false),
|
||||
signIn,
|
||||
signOut: vi.fn()
|
||||
}
|
||||
});
|
||||
|
||||
await controller.signIn();
|
||||
|
||||
expect(signIn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user