Files
geo/apps/desktop-client/src/shared/publisher-errors.test.ts
T

26 lines
980 B
TypeScript
Raw Normal View History

import { describe, expect, it } from "vitest";
import {
QIEHAO_REAL_NAME_AUTH_MESSAGE,
isQiehaoRealNameAuthError,
normalizePublisherErrorMessage,
normalizeQiehaoPublishErrorMessage,
} from "./publisher-errors";
describe("publisher error normalization", () => {
it("normalizes Qiehao real-name authentication failures from raw platform text", () => {
expect(
normalizePublisherErrorMessage("type:business, code:-5022, msg:user is not real name authentication"),
).toBe(QIEHAO_REAL_NAME_AUTH_MESSAGE);
});
it("recognizes Qiehao real-name authentication failures by business code", () => {
expect(isQiehaoRealNameAuthError("publish rejected", -5022)).toBe(true);
expect(normalizeQiehaoPublishErrorMessage("publish rejected", -5022)).toBe(QIEHAO_REAL_NAME_AUTH_MESSAGE);
});
it("leaves unknown publisher errors unchanged", () => {
expect(normalizePublisherErrorMessage("qiehao_publish_failed")).toBe("qiehao_publish_failed");
});
});