webRemoteControlAuthState.test.ts 666 B

12345678910111213141516171819
  1. import { describe, expect, it } from "vitest";
  2. import { webRemoteControlAuthStateChangeSchema } from "@zcode/shared";
  3. describe("renderer 远控登录通知契约", () => {
  4. it.each(["signed-in", "signed-out"])("接受 %s 事件", (state) => {
  5. expect(webRemoteControlAuthStateChangeSchema.parse({ state })).toEqual({ state });
  6. });
  7. it.each([
  8. null,
  9. {},
  10. [],
  11. { state: true },
  12. { state: "login" },
  13. { state: "signed-in", jwt: "secret" },
  14. { state: "signed-out", windowId: 2 },
  15. ])("拒绝非法类型与额外字段 %j", (payload) => {
  16. expect(webRemoteControlAuthStateChangeSchema.safeParse(payload).success).toBe(false);
  17. });
  18. });