test(torob): verify PostgreSQL feed regression and guard invalid pagination

This commit is contained in:
devops committed 2026-10-14 19:35:21 +00:00
1 parent d87885826c
commit 30cebb92fa
5 files changed
+108 -2

No files matched your search

@@ -140,6 +140,18 @@ describe("TorobController", () => {
expect(result.max_pages).toBe(1);
});
it.each([['garbage', 'garbage', 100], ['2', 'garbage', 100], ['garbage', '20', 20]])(
"defaults nonnumeric pagination safely (%s, %s)", async (page, size, take) => {
mockPrismaService.product.count.mockResolvedValue(0);
mockPrismaService.product.findMany.mockResolvedValue([]);
const result = await controller.getTorobProducts(page, size);
expect(mockPrismaService.product.findMany).toHaveBeenCalledWith(
expect.objectContaining({ skip: page === '2' ? 100 : 0, take }),
);
expect(result.max_pages).toBe(1);
},
);
it("should correctly mark out-of-stock products", async () => {
const mockOutOfStock = [
{