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.
66 lines
1.7 KiB
66 lines
1.7 KiB
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { saveContainer } from "@/services/cc/save-container";
|
|
import {
|
|
resetMockCcState,
|
|
setMockConflictContainers,
|
|
} from "@/services/cc/mock-state";
|
|
import { checkContainerConflict } from "@/services/cc/conflict";
|
|
|
|
vi.mock("@/services/cc/settings-config", async (importOriginal) => {
|
|
const actual =
|
|
await importOriginal<typeof import("@/services/cc/settings-config")>();
|
|
return {
|
|
...actual,
|
|
isCcMock: async () => true,
|
|
};
|
|
});
|
|
|
|
describe("cc mock", () => {
|
|
beforeEach(() => {
|
|
process.env.CC_MOCK = "true";
|
|
process.env.DATABASE_URL =
|
|
process.env.DATABASE_URL ||
|
|
"mysql://app:app@localhost:3306/email_forecast";
|
|
resetMockCcState();
|
|
});
|
|
|
|
it("SaveContainer returns ok with external id", async () => {
|
|
const res = await saveContainer({
|
|
entity: {
|
|
F_TransMode: 0,
|
|
F_OperationType: 0,
|
|
F_ContainerNo: "MATU2745683",
|
|
F_Classis: 0,
|
|
},
|
|
shipments: [
|
|
{
|
|
row_index: 1,
|
|
row_status: "VALID",
|
|
F_FBACode: "ABQ2",
|
|
F_Transporter: "TRUCK",
|
|
F_CTNS: 1,
|
|
},
|
|
{
|
|
row_index: 2,
|
|
row_status: "VALID",
|
|
F_FBACode: "FTW1",
|
|
F_Transporter: "TRUCK",
|
|
F_CTNS: 4,
|
|
},
|
|
],
|
|
});
|
|
expect(res.ok).toBe(true);
|
|
if (res.ok) expect(res.externalId).toBeTruthy();
|
|
});
|
|
|
|
it("conflict when container in mock list", async () => {
|
|
setMockConflictContainers(["MATU2745683"]);
|
|
const r = await checkContainerConflict({
|
|
containerNo: "MATU2745683",
|
|
mailId: 1n,
|
|
});
|
|
expect(r.ok).toBe(false);
|
|
if (!r.ok) expect(r.code).toBe("CONFLICT_CONTAINER");
|
|
});
|
|
});
|