示例工程 51-test-pyramid

51-test-pyramid/app/.tsc/shared/ipc.js

javascript · 1.2 KB

import { parseAddRequest, parseToggleRequest } from "./todo";
export const CH = {
    snapshot: "tests:snapshot",
    run: "tests:run",
    add: "tests:add",
    toggle: "tests:toggle",
    reportE2E: "tests:report-e2e",
    inject: "tests:inject",
    refresh: "tests:refresh",
};
export function assertAdd(value) {
    parseAddRequest(value);
}
export function assertToggle(value) {
    parseToggleRequest(value);
}
export function assertE2E(value) {
    if (typeof value !== "object" || value === null) {
        throw new Error("BAD_E2E_REPORT");
    }
    const results = value.results;
    if (!Array.isArray(results) || results.length === 0 || results.length > 12) {
        throw new Error("BAD_E2E_REPORT");
    }
    for (const row of results) {
        if (typeof row !== "object" || row === null) {
            throw new Error("BAD_E2E_ROW");
        }
        const item = row;
        if (item.layer !== "e2e" ||
            typeof item.name !== "string" ||
            typeof item.pass !== "boolean" ||
            typeof item.ms !== "number" ||
            typeof item.detail !== "string") {
            throw new Error("BAD_E2E_ROW");
        }
    }
}
//# sourceMappingURL=ipc.js.map