Skip to content

Commit

Permalink
update slot update controller to fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalsoueidan committed May 22, 2024
1 parent 111ff3f commit 2efa560
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/functions/customer/controllers/slot/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
} from "~/library/jest/azure";

import { SlotWeekDays } from "~/functions/schedule";
import { ensureType } from "~/library/jest/helpers/mock";
import { createSchedule } from "~/library/jest/helpers/schedule";
import { shopifyAdmin } from "~/library/shopify";
import { UpdateScheduleMetaobjectMutation } from "~/types/admin.generated";
import {
CustomerScheduleSlotControllerUpdate,
CustomerScheduleSlotControllerUpdateRequest,
Expand All @@ -16,6 +19,14 @@ import {

require("~/library/jest/mongoose/mongodb.jest");

jest.mock("@shopify/admin-api-client", () => ({
createAdminApiClient: () => ({
request: jest.fn(),
}),
}));

const mockRequest = shopifyAdmin.request as jest.Mock;

describe("CustomerScheduleSlotControllerUpdate", () => {
let context: InvocationContext;
let request: HttpRequest;
Expand Down Expand Up @@ -45,6 +56,25 @@ describe("CustomerScheduleSlotControllerUpdate", () => {
],
};

mockRequest.mockResolvedValueOnce({
data: ensureType<UpdateScheduleMetaobjectMutation>({
metaobjectUpdate: {
metaobject: {
fields: [
{
value: newSchedule.name,
key: "name",
},
{
value: JSON.stringify(updatedScheduleData.slots),
key: "slots",
},
],
},
},
}),
});

request =
await createHttpRequest<CustomerScheduleSlotControllerUpdateRequest>({
query: {
Expand Down

0 comments on commit 2efa560

Please sign in to comment.