mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 06:32:05 +00:00
32 lines
989 B
TypeScript
32 lines
989 B
TypeScript
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||
|
|
import { API_PATHS } from "@/api/api-paths";
|
||
|
|
|
||
|
|
const apiGet = vi.fn();
|
||
|
|
|
||
|
|
vi.mock("@/api/api", () => ({
|
||
|
|
apiGet: (...args: unknown[]) => apiGet(...args),
|
||
|
|
apiPost: vi.fn(),
|
||
|
|
}));
|
||
|
|
|
||
|
|
import { assetsApi } from "@/domain/assets/api/assets-api";
|
||
|
|
|
||
|
|
describe("assetsApi.getSiteOptions", () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
apiGet.mockReset();
|
||
|
|
apiGet.mockResolvedValue({
|
||
|
|
Data: [{ Id: 1, Name: "Site A", Title: "Site A Title" }],
|
||
|
|
TotalCount: 1,
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it("loads locations via Location/GetLocationList instead of Common/GetSitesName", async () => {
|
||
|
|
const sites = await assetsApi.getSiteOptions();
|
||
|
|
|
||
|
|
expect(apiGet).toHaveBeenCalledWith(API_PATHS.location.getList, {
|
||
|
|
searchParams: { search: "", page: 1, pageSize: 1000 },
|
||
|
|
});
|
||
|
|
expect(apiGet).not.toHaveBeenCalledWith("Common/GetSitesName", expect.anything());
|
||
|
|
expect(sites).toEqual([{ id: 1, name: "Site A", title: "Site A Title" }]);
|
||
|
|
});
|
||
|
|
});
|