Skip to content

Commit

Permalink
alter mock fn in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Sep 17, 2024
1 parent 53f70a5 commit 702fe1b
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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 () => {
Expand All @@ -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);

Expand All @@ -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 () => {
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 702fe1b

Please sign in to comment.