feat: launch local-first Sudoku workbench
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { cleanup } from "@testing-library/react";
|
||||
import { afterEach, vi } from "vitest";
|
||||
|
||||
if (
|
||||
!(
|
||||
HTMLDialogElement.prototype as HTMLDialogElement & {
|
||||
showModal?: () => void;
|
||||
}
|
||||
).showModal
|
||||
) {
|
||||
HTMLDialogElement.prototype.showModal = function showModal() {
|
||||
this.setAttribute("open", "");
|
||||
};
|
||||
}
|
||||
|
||||
const nativeDialogClose = HTMLDialogElement.prototype.close;
|
||||
HTMLDialogElement.prototype.close = function close(returnValue?: string) {
|
||||
if (nativeDialogClose) {
|
||||
try {
|
||||
nativeDialogClose.call(this, returnValue);
|
||||
return;
|
||||
} catch {
|
||||
// jsdom fallback.
|
||||
}
|
||||
}
|
||||
this.removeAttribute("open");
|
||||
};
|
||||
|
||||
Object.defineProperty(URL, "createObjectURL", {
|
||||
configurable: true,
|
||||
value: vi.fn(() => "blob:sudoku-tools-test"),
|
||||
});
|
||||
Object.defineProperty(URL, "revokeObjectURL", {
|
||||
configurable: true,
|
||||
value: vi.fn(),
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
Reference in New Issue
Block a user