- GET /api/entities/{set}/$count a /api/<resource>/$count: pocet zaznamu
jednim volanim SAPu, podporuje $filter, vraci { count }
- $inlinecount=allpages (alias $count=true) se predava do Service Layeru
- /all posila Prefer: odata.maxpagesize podle SAP_B1_PAGE_SIZE (vychozi 500)
misto vychozich 20 zaznamu na stranku
- Swagger, README, .env.example, dokumentace a testy
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildODataParams, extractNextLink } from "../src/client/odata";
|
|
|
|
describe("OData helpers", () => {
|
|
it("builds SAP Service Layer OData query parameters", () => {
|
|
expect(
|
|
buildODataParams({
|
|
select: ["CardCode", "CardName"],
|
|
filter: "CardType eq 'cCustomer'",
|
|
top: 25,
|
|
skip: 50,
|
|
orderby: ["CardName asc", "CardCode desc"]
|
|
})
|
|
).toEqual({
|
|
$select: "CardCode,CardName",
|
|
$filter: "CardType eq 'cCustomer'",
|
|
$top: 25,
|
|
$skip: 50,
|
|
$orderby: "CardName asc,CardCode desc"
|
|
});
|
|
});
|
|
|
|
it("passes $inlinecount through to Service Layer", () => {
|
|
expect(buildODataParams({ top: 1, inlinecount: "allpages" })).toEqual({ $top: 1, $inlinecount: "allpages" });
|
|
});
|
|
|
|
it("supports old and new nextLink field names", () => {
|
|
expect(extractNextLink({ "@odata.nextLink": "Items?$skip=20" })).toBe("Items?$skip=20");
|
|
expect(extractNextLink({ "odata.nextLink": "Items?$skip=40" })).toBe("Items?$skip=40");
|
|
});
|
|
});
|