zerobyte/app/server/modules/sso/__tests__/sso.errors.test.ts
Nico 4305057185
test: move test runner from Bun to Vitest (#727)
* chore: migrate to vitest

* test: speed up some suites by sharing sessions and mocking expensive non-tested actions

* test: refactor some tests to verify behavior instead of implementation details

* chore: fix linting issues
2026-04-01 20:05:54 +02:00

32 lines
1.2 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { mapAuthErrorToCode } from "../sso.errors";
describe("mapAuthErrorToCode", () => {
test("maps account-not-linked errors to ACCOUNT_LINK_REQUIRED", () => {
expect(mapAuthErrorToCode(encodeURIComponent("account not linked"))).toBe("ACCOUNT_LINK_REQUIRED");
});
test("maps unable-to-link-account errors to ACCOUNT_LINK_REQUIRED", () => {
expect(mapAuthErrorToCode(encodeURIComponent("unable to link account"))).toBe("ACCOUNT_LINK_REQUIRED");
});
test("maps security account-linking denial to ACCOUNT_LINK_REQUIRED", () => {
expect(
mapAuthErrorToCode(
encodeURIComponent("SSO account linking is not permitted for users outside this organization"),
),
).toBe("ACCOUNT_LINK_REQUIRED");
});
test("maps invite-required errors to INVITE_REQUIRED", () => {
expect(
mapAuthErrorToCode(
encodeURIComponent("Access denied. You must be invited to this organization before you can sign in with SSO."),
),
).toBe("INVITE_REQUIRED");
});
test("maps unknown errors to SSO_LOGIN_FAILED", () => {
expect(mapAuthErrorToCode(encodeURIComponent("some random error"))).toBe("SSO_LOGIN_FAILED");
});
});