Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus committed Mar 9, 2022
1 parent 8b97b86 commit 7c4bf6d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/composables/__tests__/useCms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,25 @@ describe("Composables - useCms", () => {
it("should performs search with pagination if provided", async () => {
const { search, page } = useCms();
let invocationCriteria: any = null;
const mockedParams = {
limit: 50
}
mockedHelpers._parseUrlQuery.mockReturnValueOnce(mockedParams as any);
mockedGetPage.getCmsPage.mockImplementationOnce(
async (path: string, searchCriteria, apiInstance): Promise<any> => {
invocationCriteria = searchCriteria;
return {};
}
);
expect(page.value).toEqual(null);
await search("", { limit: 50 });
await search("", mockedParams);
expect(mockedGetPage.getCmsPage).toBeCalledWith(
"",
expect.any(Object),
rootContextMock.apiInstance
);
expect(invocationCriteria?.limit).toEqual(50);

});

it("should provide default includes if not provided, but configuration exist", async () => {
Expand Down Expand Up @@ -226,10 +231,12 @@ describe("Composables - useCms", () => {
return {};
}
);
expect(page.value).toEqual(null);
await search("", {
const searchParams = {
includes: { product: ["someCustomField"] },
});
}
mockedHelpers._parseUrlQuery.mockReturnValueOnce(searchParams as any)
expect(page.value).toEqual(null);
await search("", searchParams);
expect(mockedGetPage.getCmsPage).toBeCalledWith(
"",
expect.any(Object),
Expand Down

0 comments on commit 7c4bf6d

Please sign in to comment.