🤡(react) add HTMLDialog mock

As JestDOM does not mock this element, we need to do it in order to
make Modal work in test environement.
This commit is contained in:
Nathan Vasse
2024-01-18 14:38:00 +01:00
committed by NathanVss
parent 141d712a47
commit 7dcf08d308
2 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
HTMLDialogElement.prototype.show = vi.fn(function mock(
this: HTMLDialogElement,
) {
this.open = true;
});
HTMLDialogElement.prototype.showModal = vi.fn(function mock(
this: HTMLDialogElement,
) {
this.open = true;
});
HTMLDialogElement.prototype.close = vi.fn(function mock(
this: HTMLDialogElement,
) {
this.open = false;
});

View File

@@ -2,6 +2,7 @@ import "@testing-library/jest-dom/vitest";
import createFetchMock from "vitest-fetch-mock";
import { vi } from "vitest";
import "./AnimateMock";
import "./HTMLDialogElementMock";
const fetchMocker = createFetchMock(vi);