🤡(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:
17
packages/react/src/tests/HTMLDialogElementMock.ts
Normal file
17
packages/react/src/tests/HTMLDialogElementMock.ts
Normal 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;
|
||||||
|
});
|
||||||
@@ -2,6 +2,7 @@ import "@testing-library/jest-dom/vitest";
|
|||||||
import createFetchMock from "vitest-fetch-mock";
|
import createFetchMock from "vitest-fetch-mock";
|
||||||
import { vi } from "vitest";
|
import { vi } from "vitest";
|
||||||
import "./AnimateMock";
|
import "./AnimateMock";
|
||||||
|
import "./HTMLDialogElementMock";
|
||||||
|
|
||||||
const fetchMocker = createFetchMock(vi);
|
const fetchMocker = createFetchMock(vi);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user