27 lines
658 B
TypeScript
27 lines
658 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import {
|
|
isAuthRequestMessage,
|
|
isAuthResponseMessage
|
|
} from "../src/shared/auth-messages";
|
|
|
|
describe("auth-messages", () => {
|
|
test("accepts a get-state request", () => {
|
|
expect(isAuthRequestMessage({ type: "auth:get-state" })).toBe(true);
|
|
});
|
|
|
|
test("rejects unknown auth requests", () => {
|
|
expect(isAuthRequestMessage({ type: "auth:wat" })).toBe(false);
|
|
});
|
|
|
|
test("accepts a successful auth response envelope", () => {
|
|
expect(
|
|
isAuthResponseMessage({
|
|
ok: true,
|
|
type: "auth:state",
|
|
value: { isAuthenticated: false }
|
|
})
|
|
).toBe(true);
|
|
});
|
|
});
|