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.
58 lines
1.7 KiB
58 lines
1.7 KiB
import { describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("@/lib/axel/candidates", () => ({
|
|
resolveAxelMothershipCandidates: vi.fn(),
|
|
}));
|
|
|
|
import { resolveMothershipCandidates } from "@/modules/address/mothership-candidates";
|
|
import { resolveAxelMothershipCandidates } from "@/lib/axel/candidates";
|
|
|
|
describe("resolveMothershipCandidates", () => {
|
|
const input = {
|
|
pickup: {
|
|
street: "5678 Distribution Dr",
|
|
city: "Dallas",
|
|
state: "TX",
|
|
zip: "75201",
|
|
},
|
|
delivery: {
|
|
street: "1234 Warehouse Blvd",
|
|
city: "Los Angeles",
|
|
state: "CA",
|
|
zip: "90001",
|
|
},
|
|
};
|
|
|
|
it("非 mock 模式统一走 axel search", async () => {
|
|
process.env.RPA_MOCK_MODE = "false";
|
|
vi.mocked(resolveAxelMothershipCandidates).mockResolvedValue({
|
|
pickup_candidates: [
|
|
{
|
|
option_id: "ChIJpickup",
|
|
display_label: "5678 Distribution Dr, Dallas, TX 75201",
|
|
formatted_address: "5678 Distribution Dr, Dallas, TX 75201",
|
|
street: "5678 Distribution Dr",
|
|
city: "Dallas",
|
|
state: "TX",
|
|
zip: "75201",
|
|
},
|
|
],
|
|
delivery_candidates: [
|
|
{
|
|
option_id: "ChIJdelivery",
|
|
display_label: "1234 Warehouse Blvd, Los Angeles, CA 90001",
|
|
formatted_address: "1234 Warehouse Blvd, Los Angeles, CA 90001",
|
|
street: "1234 Warehouse Blvd",
|
|
city: "Los Angeles",
|
|
state: "CA",
|
|
zip: "90001",
|
|
},
|
|
],
|
|
});
|
|
|
|
const result = await resolveMothershipCandidates(input);
|
|
expect(resolveAxelMothershipCandidates).toHaveBeenCalledWith(input);
|
|
expect(result.pickup_candidates[0].option_id).toBe("ChIJpickup");
|
|
});
|
|
});
|