lookup vehicle-kinds added

This commit is contained in:
2026-09-28 17:09:45 +03:30
parent efef48d824
commit 7a8d96ab52
10 changed files with 614 additions and 10 deletions

View File

@@ -0,0 +1,54 @@
import { LookupsService } from "./lookups.service";
describe("LookupsService.searchVehicleKindsList", () => {
it("echoes q and returns active Caption matches for typeahead", async () => {
const searchActiveByCaption = jest.fn().mockResolvedValue([
{
Id: 6645,
Caption: "کاميون کشنده ولوو FH12 4*2",
IsActive: 1,
},
]);
const service = new LookupsService({} as any, {} as any, {
countDocuments: jest.fn().mockResolvedValue(10),
getLatestSyncedAt: jest.fn().mockResolvedValue(new Date()),
findAllPublic: jest.fn().mockResolvedValue([]),
searchActiveByCaption,
replaceAllFromFanavaran: jest.fn(),
} as any);
const result = await service.searchVehicleKindsList({ q: "ول", limit: 20 });
expect(result).toEqual({
q: "ول",
count: 1,
items: [
{
Id: 6645,
Caption: "کاميون کشنده ولوو FH12 4*2",
IsActive: 1,
},
],
});
expect(searchActiveByCaption).toHaveBeenCalledWith("ول", 20);
});
it("returns empty items for blank q without searching", async () => {
const searchActiveByCaption = jest.fn();
const service = new LookupsService({} as any, {} as any, {
countDocuments: jest.fn().mockResolvedValue(10),
getLatestSyncedAt: jest.fn().mockResolvedValue(new Date()),
findAllPublic: jest.fn().mockResolvedValue([]),
searchActiveByCaption,
replaceAllFromFanavaran: jest.fn(),
} as any);
await expect(service.searchVehicleKindsList({ q: " " })).resolves.toEqual({
q: "",
count: 0,
items: [],
});
expect(searchActiveByCaption).not.toHaveBeenCalled();
});
});