Skip to content

Commit

Permalink
cm17 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Oct 17, 2024
1 parent ed9ce36 commit 37fc710
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("MenuOptionArchiveRename", () => {
function mockModal() {
modalSpy.mockReset();
modalSpy = jest.spyOn(ModalArchiveRename, "default").mockImplementation(() => {
return <h1 data-test="modal-archive-mkdir">test</h1>;
return <h1 data-test="modal-archive-rename">test</h1>;
});
}

Expand All @@ -33,18 +33,19 @@ describe("MenuOptionArchiveRename", () => {
it("should not show the modal initially", () => {
mockModal();
const component = renderComponent();
expect(screen.queryByTestId("modal-archive-mkdir")).not.toBeTruthy();
expect(screen.queryByTestId("modal-archive-rename")).not.toBeTruthy();
expect(modalSpy).toHaveBeenCalledTimes(0);
component.unmount();
});

it("should open the modal when the button is clicked", () => {
mockModal();
const component = renderComponent();
fireEvent.click(screen.getByTestId("mkdir"));

fireEvent.click(screen.getByTestId("rename"));
expect(modalSpy).toHaveBeenCalledTimes(1);

expect(screen.getByTestId("modal-archive-mkdir")).toBeTruthy();
expect(screen.getByTestId("modal-archive-rename")).toBeTruthy();
component.unmount();
});

Expand All @@ -53,11 +54,8 @@ describe("MenuOptionArchiveRename", () => {
mockModalHandleExit();

const component = renderComponent();
fireEvent.click(screen.getByTestId("mkdir"));
expect(screen.getByTestId("mkdir")).toBeTruthy();

// Simulate closing the modal
fireEvent.click(screen.getByTestId("mkdir"));
fireEvent.click(screen.getByTestId("rename"));
expect(screen.getByTestId("rename")).toBeTruthy();

expect(stateSpy).toHaveBeenCalledTimes(1);
expect(stateSpy).toHaveBeenCalledWith(false);
Expand All @@ -68,8 +66,8 @@ describe("MenuOptionArchiveRename", () => {
mockModal();

const component = renderComponent(true);
fireEvent.click(screen.getByTestId("mkdir"));
expect(screen.queryByTestId("modal-archive-mkdir")).not.toBeTruthy();
fireEvent.click(screen.getByTestId("rename"));
expect(screen.queryByTestId("modal-archive-rename")).not.toBeTruthy();
component.unmount();
});
});

0 comments on commit 37fc710

Please sign in to comment.