@terpjs/react-core 0.25.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vitest.setup.ts CHANGED
@@ -5,6 +5,8 @@ import "@testing-library/jest-dom/vitest";
5
5
 
6
6
  import { configure } from "@testing-library/dom";
7
7
 
8
+ import { installDialogPolyfill } from "@terpjs/react-core/testing";
9
+
8
10
  // `findBy*` and `waitFor` default to a 1000ms budget, and the component tests spend it on
9
11
  // a path that is not a render: a mocked fetch resolving, then the state it sets, then the
10
12
  // re-render that finally puts the text on screen. One second does not reliably cover that,
@@ -93,23 +95,8 @@ if (typeof window !== "undefined") {
93
95
  window.scrollTo = (() => {}) as typeof window.scrollTo;
94
96
  }
95
97
 
96
-
97
- // jsdom does not implement the native <dialog> modal API (showModal/close); polyfill just
98
- // enough for the ConfirmDialog tests: toggle the `open` property and fire the `close` event.
99
- if (typeof window !== "undefined" && typeof HTMLDialogElement !== "undefined") {
100
- const proto = HTMLDialogElement.prototype as HTMLDialogElement & {
101
- showModal?: () => void;
102
- close?: () => void;
103
- };
104
- if (typeof proto.showModal !== "function") {
105
- proto.showModal = function showModal(this: HTMLDialogElement) {
106
- this.setAttribute("open", "");
107
- };
108
- }
109
- if (typeof proto.close !== "function") {
110
- proto.close = function close(this: HTMLDialogElement) {
111
- this.removeAttribute("open");
112
- this.dispatchEvent(new Event("close"));
113
- };
114
- }
115
- }
98
+ // jsdom has no `showModal()` / `close()`, and ConfirmDialog calls both. The polyfill is the
99
+ // one every generated app's setup file installs, imported through the same published subpath
100
+ // rather than by relative path, so this suite also proves the export an app resolves exists.
101
+ // A no-op in the node-environment files, which have no HTMLDialogElement.
102
+ installDialogPolyfill();