@trackunit/react-vite-test-setup 0.0.205-alpha-1872e1df7fb.0 → 0.0.205
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/index.cjs.js +19 -0
- package/index.esm.js +19 -1
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/setupLexical.d.ts +14 -0
package/index.cjs.js
CHANGED
|
@@ -1408,6 +1408,24 @@ const setupDefaultMocks = (options = {}) => {
|
|
|
1408
1408
|
setupTranslations();
|
|
1409
1409
|
};
|
|
1410
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* Sets up the browser APIs that the Lexical editor needs and JSDOM leaves out.
|
|
1413
|
+
*
|
|
1414
|
+
* Without `InputEvent.getTargetRanges`, Lexical ignores the `beforeinput` events that user-event sends,
|
|
1415
|
+
* so typing does nothing. Without `Range.getBoundingClientRect`, it fails when it scrolls to the caret
|
|
1416
|
+
* or places a typeahead menu.
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* // In your vitest setup file
|
|
1420
|
+
* import { setupLexical } from '@trackunit/react-vite-test-setup';
|
|
1421
|
+
*
|
|
1422
|
+
* setupLexical();
|
|
1423
|
+
*/
|
|
1424
|
+
const setupLexical = () => {
|
|
1425
|
+
Object.defineProperty(InputEvent.prototype, "getTargetRanges", { configurable: true, value: () => [] });
|
|
1426
|
+
Object.defineProperty(Range.prototype, "getBoundingClientRect", { configurable: true, value: () => new DOMRect() });
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1411
1429
|
/**
|
|
1412
1430
|
* Mocks the `@tanstack/react-router` library for testing environments.
|
|
1413
1431
|
*
|
|
@@ -1448,6 +1466,7 @@ exports.setupFailOnConsole = setupFailOnConsole;
|
|
|
1448
1466
|
exports.setupGoogleMaps = setupGoogleMaps;
|
|
1449
1467
|
exports.setupHelmetMock = setupHelmetMock;
|
|
1450
1468
|
exports.setupIntersectionObserver = setupIntersectionObserver;
|
|
1469
|
+
exports.setupLexical = setupLexical;
|
|
1451
1470
|
exports.setupMapbox = setupMapbox;
|
|
1452
1471
|
exports.setupMatchMediaMock = setupMatchMediaMock;
|
|
1453
1472
|
exports.setupReactTestingLibrary = setupReactTestingLibrary;
|
package/index.esm.js
CHANGED
|
@@ -1387,6 +1387,24 @@ const setupDefaultMocks = (options = {}) => {
|
|
|
1387
1387
|
setupTranslations();
|
|
1388
1388
|
};
|
|
1389
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* Sets up the browser APIs that the Lexical editor needs and JSDOM leaves out.
|
|
1392
|
+
*
|
|
1393
|
+
* Without `InputEvent.getTargetRanges`, Lexical ignores the `beforeinput` events that user-event sends,
|
|
1394
|
+
* so typing does nothing. Without `Range.getBoundingClientRect`, it fails when it scrolls to the caret
|
|
1395
|
+
* or places a typeahead menu.
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* // In your vitest setup file
|
|
1399
|
+
* import { setupLexical } from '@trackunit/react-vite-test-setup';
|
|
1400
|
+
*
|
|
1401
|
+
* setupLexical();
|
|
1402
|
+
*/
|
|
1403
|
+
const setupLexical = () => {
|
|
1404
|
+
Object.defineProperty(InputEvent.prototype, "getTargetRanges", { configurable: true, value: () => [] });
|
|
1405
|
+
Object.defineProperty(Range.prototype, "getBoundingClientRect", { configurable: true, value: () => new DOMRect() });
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1390
1408
|
/**
|
|
1391
1409
|
* Mocks the `@tanstack/react-router` library for testing environments.
|
|
1392
1410
|
*
|
|
@@ -1413,4 +1431,4 @@ const setupTanstackReactRouter = () => {
|
|
|
1413
1431
|
}));
|
|
1414
1432
|
};
|
|
1415
1433
|
|
|
1416
|
-
export { configureReliableAsyncUtils, createMockClickEvent, createMockMapboxMap, resetTanstackReactVirtualMock, setTanstackReactVirtualItems, setTanstackReactVirtualStableInstance, setupAllMocks, setupBasicMocks, setupCanvasMock, setupDefaultMocks, setupFailOnConsole, setupGoogleMaps, setupHelmetMock, setupIntersectionObserver, setupMapbox, setupMatchMediaMock, setupReactTestingLibrary, setupReactVirtualizedAutoSizer, setupResizeObserver, setupTanstackReactRouter, setupTanstackReactVirtual, setupTimeAndLanguage, setupTimeZone, setupTranslations, setupWebStreams, tanstackReactVirtualMock };
|
|
1434
|
+
export { configureReliableAsyncUtils, createMockClickEvent, createMockMapboxMap, resetTanstackReactVirtualMock, setTanstackReactVirtualItems, setTanstackReactVirtualStableInstance, setupAllMocks, setupBasicMocks, setupCanvasMock, setupDefaultMocks, setupFailOnConsole, setupGoogleMaps, setupHelmetMock, setupIntersectionObserver, setupLexical, setupMapbox, setupMatchMediaMock, setupReactTestingLibrary, setupReactVirtualizedAutoSizer, setupResizeObserver, setupTanstackReactRouter, setupTanstackReactVirtual, setupTimeAndLanguage, setupTimeZone, setupTranslations, setupWebStreams, tanstackReactVirtualMock };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-vite-test-setup",
|
|
3
3
|
"description": "Test setup utilities for React applications",
|
|
4
|
-
"version": "0.0.205
|
|
4
|
+
"version": "0.0.205",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
7
|
"engines": {
|
package/src/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./setupFailOnConsole";
|
|
|
7
7
|
export * from "./setupGoogleMaps";
|
|
8
8
|
export * from "./setupHelmetMock";
|
|
9
9
|
export * from "./setupIntersectionObserver";
|
|
10
|
+
export * from "./setupLexical";
|
|
10
11
|
export * from "./setupMapbox";
|
|
11
12
|
export * from "./setupMatchMediaMock";
|
|
12
13
|
export * from "./setupReactTestingLibrary";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets up the browser APIs that the Lexical editor needs and JSDOM leaves out.
|
|
3
|
+
*
|
|
4
|
+
* Without `InputEvent.getTargetRanges`, Lexical ignores the `beforeinput` events that user-event sends,
|
|
5
|
+
* so typing does nothing. Without `Range.getBoundingClientRect`, it fails when it scrolls to the caret
|
|
6
|
+
* or places a typeahead menu.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // In your vitest setup file
|
|
10
|
+
* import { setupLexical } from '@trackunit/react-vite-test-setup';
|
|
11
|
+
*
|
|
12
|
+
* setupLexical();
|
|
13
|
+
*/
|
|
14
|
+
export declare const setupLexical: () => void;
|