You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
import { describe, expect, it } from "vitest";
|
|
import { shouldEnqueueCompensation } from "@/services/cc/save-container";
|
|
|
|
describe("shouldEnqueueCompensation", () => {
|
|
it("timeout → TIMEOUT_UNKNOWN", () => {
|
|
expect(
|
|
shouldEnqueueCompensation({
|
|
ok: false,
|
|
status: "TIMEOUT_UNKNOWN",
|
|
error: "CC request timeout",
|
|
requestBody: "{}",
|
|
}),
|
|
).toBe("TIMEOUT_UNKNOWN");
|
|
});
|
|
|
|
it("500 → CC_5XX", () => {
|
|
expect(
|
|
shouldEnqueueCompensation({
|
|
ok: false,
|
|
status: "FAILED",
|
|
error: "Internal Server Error",
|
|
requestBody: "{}",
|
|
response: { code: 500, info: "Internal Server Error" },
|
|
}),
|
|
).toBe("CC_5XX");
|
|
});
|
|
|
|
it("401 / 400 do not enqueue", () => {
|
|
expect(
|
|
shouldEnqueueCompensation({
|
|
ok: false,
|
|
status: "FAILED",
|
|
error: "Unauthorized",
|
|
requestBody: "{}",
|
|
response: { code: 401, info: "Unauthorized" },
|
|
}),
|
|
).toBeNull();
|
|
expect(
|
|
shouldEnqueueCompensation({
|
|
ok: false,
|
|
status: "FAILED",
|
|
error: "Bad Request",
|
|
requestBody: "{}",
|
|
response: { code: 400, info: "Bad Request" },
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|