Skip to content

Commit

Permalink
🐛 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoLyn committed Jul 1, 2024
1 parent 8d053ee commit 2dfa1a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
8 changes: 0 additions & 8 deletions src/components/search/__test__/ComplexTextSearch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ vi.mock("../../common/filters/AdvanceFilters.tsx", () => {
return { default: mockAdvanceFilters };
});

const ResizeObserverMock = vi.fn(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));

vi.stubGlobal("ResizeObserver", ResizeObserverMock);

beforeAll(() => {
server.listen();
});
Expand Down
8 changes: 0 additions & 8 deletions src/components/search/__test__/InputWithSuggester.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ import InputWithSuggester from "../InputWithSuggester";
import { server } from "../../../__mocks__/server";
import { userEvent } from "@testing-library/user-event";

const ResizeObserverMock = vi.fn(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));

vi.stubGlobal("ResizeObserver", ResizeObserverMock);

beforeAll(() => {
server.listen();
});
Expand Down
19 changes: 19 additions & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom";

class ResizeObserver {
callback: ResizeObserverCallback;

constructor(callback: ResizeObserverCallback) {
this.callback = callback;
}

observe() {
// Trigger the callback immediately to simulate observing behavior
this.callback([], this);
}

unobserve() {}

disconnect() {}
}

(global as any).ResizeObserver = ResizeObserver;

0 comments on commit 2dfa1a8

Please sign in to comment.