From 702fe1b1aaffd75ba9c22748d4561af7203fcd5d Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 17 Sep 2024 12:35:04 +0100 Subject: [PATCH] alter mock fn in tests --- .../tests/TeamMembers.updateEditor.test.tsx | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.updateEditor.test.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.updateEditor.test.tsx index 0ee83e2ae2..5d7884add8 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.updateEditor.test.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.updateEditor.test.tsx @@ -6,14 +6,11 @@ import { setupTeamMembersScreen } from "./helpers/setupTeamMembersScreen"; import { mockTeamMembersData } from "./mocks/mockTeamMembersData"; import { mockPlainUser, mockPlatformAdminUser } from "./mocks/mockUsers"; -vi.mock( - "pages/FlowEditor/components/Team/queries/createAndAddUserToTeam.tsx", - () => ({ - updateTeamMember: vi.fn().mockResolvedValue({ - id: 1, - }), +vi.mock("pages/FlowEditor/components/Team/queries/updateUser.tsx", () => ({ + updateTeamMember: vi.fn().mockResolvedValue({ + id: 1, }), -); +})); describe("when a user presses 'edit button'", () => { beforeEach(async () => { @@ -26,7 +23,7 @@ describe("when a user presses 'edit button'", () => { const teamEditorsTable = screen.getByTestId("team-editors"); const addEditorButton = await within(teamEditorsTable).findByTestId( - "edit-button-0", + "edit-button-0" ); user.click(addEditorButton); @@ -66,7 +63,7 @@ describe("when a user deletes an input value", () => { const teamEditorsTable = screen.getByTestId("team-editors"); const addEditorButton = await within(teamEditorsTable).findByTestId( - "edit-button-0", + "edit-button-0" ); await user.click(addEditorButton); @@ -100,7 +97,7 @@ describe("when a user updates a field correctly", () => { const teamEditorsTable = screen.getByTestId("team-editors"); const addEditorButton = await within(teamEditorsTable).findByTestId( - "edit-button-0", + "edit-button-0" ); await user.click(addEditorButton); @@ -114,7 +111,7 @@ describe("when a user updates a field correctly", () => { it("updates the field", async () => { const firstNameInput = await screen.findByLabelText("First name"); expect(firstNameInput).toHaveDisplayValue( - mockTeamMembersData[1].firstName + "bo", + mockTeamMembersData[1].firstName + "bo" ); }); it("enables the update user button", async () => { @@ -132,7 +129,7 @@ describe("when a user correctly updates an Editor", () => { const teamEditorsTable = screen.getByTestId("team-editors"); const addEditorButton = await within(teamEditorsTable).findByTestId( - "edit-button-0", + "edit-button-0" ); await user.click(addEditorButton); @@ -152,7 +149,7 @@ describe("when a user correctly updates an Editor", () => { expect(within(membersTable).getByText(/Billbo/)).toBeInTheDocument(); }); expect( - await screen.findByText(/Successfully updated a user/), + await screen.findByText(/Successfully updated a user/) ).toBeInTheDocument(); }); it("closes the modal", async () => { @@ -162,7 +159,7 @@ describe("when a user correctly updates an Editor", () => { }); it("shows a success message", async () => { expect( - await screen.findByText(/Successfully updated a user/), + await screen.findByText(/Successfully updated a user/) ).toBeInTheDocument(); }); });