@pie-lib/test-utils 1.1.0-next.4 → 1.1.1-next.1
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/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_react2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_styles","_userEvent","_jestDom","_keyboard","_webComponents","_excluded","_excluded2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","set","_t","getOwnPropertyDescriptor","ownKeys","getOwnPropertySymbols","filter","push","apply","_objectSpread","arguments","length","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defaultTheme","createTheme","renderWithTheme","ui","options","undefined","_options$theme","theme","renderOptions","_objectWithoutProperties2","Wrapper","_ref","children","createElement","ThemeProvider","propTypes","PropTypes","node","render","wrapper","renderWithProviders","_options$theme2","_options$providers","providers","_ref2","wrapped","Provider","createTestTheme","themeOptions"],"sources":["../src/index.js"],"sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { render } from '@testing-library/react';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_react2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_styles","_userEvent","_jestDom","_keyboard","_webComponents","_excluded","_excluded2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","set","_t","getOwnPropertyDescriptor","ownKeys","getOwnPropertySymbols","filter","push","apply","_objectSpread","arguments","length","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defaultTheme","createTheme","renderWithTheme","ui","options","undefined","_options$theme","theme","renderOptions","_objectWithoutProperties2","Wrapper","_ref","children","createElement","ThemeProvider","propTypes","PropTypes","node","render","wrapper","renderWithProviders","_options$theme2","_options$providers","providers","_ref2","wrapped","Provider","createTestTheme","themeOptions"],"sources":["../src/index.js"],"sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { render } from '@testing-library/react';\nimport { createTheme, ThemeProvider } from '@mui/material/styles';\n\n/**\n * Default MUI theme for testing\n */\nconst defaultTheme = createTheme();\n\n/**\n * Render a component with MUI ThemeProvider\n *\n * @param {React.ReactElement} ui - The component to render\n * @param {Object} options - Render options\n * @param {Object} options.theme - Custom MUI theme (optional)\n * @param {Object} options.renderOptions - Additional options passed to RTL render\n * @returns {Object} RTL render result\n *\n * @example\n * const { getByRole } = renderWithTheme(<Button>Click me</Button>);\n * expect(getByRole('button')).toBeInTheDocument();\n */\nexport function renderWithTheme(ui, options = {}) {\n const { theme = defaultTheme, ...renderOptions } = options;\n\n function Wrapper({ children }) {\n return <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n }\n Wrapper.propTypes = {\n children: PropTypes.node,\n };\n\n return render(ui, { wrapper: Wrapper, ...renderOptions });\n}\n\n/**\n * Render a component with multiple providers (Theme, etc.)\n * Useful when you need to wrap components with various context providers\n *\n * @param {React.ReactElement} ui - The component to render\n * @param {Object} options - Render options\n * @param {Object} options.theme - Custom MUI theme (optional)\n * @param {Array<React.ComponentType>} options.providers - Additional providers to wrap\n * @param {Object} options.renderOptions - Additional options passed to RTL render\n * @returns {Object} RTL render result\n *\n * @example\n * const { getByText } = renderWithProviders(\n * <MyComponent />,\n * { providers: [ReduxProvider, RouterProvider] }\n * );\n */\nexport function renderWithProviders(ui, options = {}) {\n const { theme = defaultTheme, providers = [], ...renderOptions } = options;\n\n function Wrapper({ children }) {\n let wrapped = <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n\n // Wrap with additional providers (from innermost to outermost)\n providers.forEach((Provider) => {\n wrapped = <Provider>{wrapped}</Provider>;\n });\n\n return wrapped;\n }\n Wrapper.propTypes = {\n children: PropTypes.node,\n };\n\n return render(ui, { wrapper: Wrapper, ...renderOptions });\n}\n\n/**\n * Create a custom theme for testing\n * Useful for testing components with specific theme configurations\n *\n * @param {Object} themeOptions - MUI theme options\n * @returns {Object} MUI theme\n *\n * @example\n * const darkTheme = createTestTheme({ palette: { mode: 'dark' } });\n * renderWithTheme(<Component />, { theme: darkTheme });\n */\nexport function createTestTheme(themeOptions = {}) {\n return createTheme(themeOptions);\n}\n\n/**\n * Wait for an element to be removed from the DOM\n * Wrapper around waitForElementToBeRemoved for convenience\n *\n * @example\n * await waitForRemoval(() => screen.queryByText('Loading...'));\n */\nexport { waitForElementToBeRemoved as waitForRemoval } from '@testing-library/react';\n\n/**\n * Re-export all of @testing-library/react for convenience\n * This allows consumers to import everything from one place\n */\nexport * from '@testing-library/react';\n\n/**\n * Re-export userEvent as a named export for convenience\n */\nexport { default as userEvent } from '@testing-library/user-event';\n\n/**\n * Re-export jest-dom matchers (they're automatically added in jest.setup.js,\n * but we export them here for TypeScript support)\n */\nexport * from '@testing-library/jest-dom';\n\n/**\n * Keyboard helpers for testing keyboard interactions\n * Especially useful for components checking event.keyCode\n */\nexport {\n Keys,\n pressKey,\n typeAndSubmit,\n clearAndType,\n navigateWithKeys,\n} from './keyboard';\n\n/**\n * Web component testing utilities\n * For testing light DOM custom elements (no Shadow DOM)\n */\nexport {\n waitForCustomElement,\n renderWebComponent,\n dispatchCustomEvent,\n waitForEvent,\n isCustomElementDefined,\n createCustomElement,\n} from './web-components';\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAmGAI,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA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AAA,IAAnBC,YAAY,GAAAjC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAU,SAAA,GAAAV,SAAA,MAAG,CAAC,CAAC;EAC/C,OAAO,IAAAM,mBAAW,EAAC2B,YAAY,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/test-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1-next.1",
|
|
4
4
|
"description": "Testing utilities for pie-lib packages with React Testing Library and MUI support",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"@testing-library/jest-dom": "^5.16.5",
|
|
22
22
|
"@testing-library/user-event": "^14.5.2"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "87d7d9ee63abeb5eff95f888cc2b80683c81ea13",
|
|
25
25
|
"scripts": {}
|
|
26
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { createTestTheme, renderWithProviders, renderWithTheme, screen } from '../index';
|
|
3
3
|
import { Button } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
describe('@pie-lib/test-utils', () => {
|
|
@@ -42,9 +42,7 @@ describe('@pie-lib/test-utils', () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('renders with additional providers', () => {
|
|
45
|
-
const TestProvider = ({ children }) =>
|
|
46
|
-
<div data-testid="test-provider">{children}</div>
|
|
47
|
-
);
|
|
45
|
+
const TestProvider = ({ children }) => <div data-testid="test-provider">{children}</div>;
|
|
48
46
|
|
|
49
47
|
renderWithProviders(<Button>Multi Provider</Button>, {
|
|
50
48
|
providers: [TestProvider],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { clearAndType, Keys, navigateWithKeys, pressKey, typeAndSubmit } from '../keyboard';
|
|
4
4
|
|
|
5
5
|
describe('Keyboard helpers', () => {
|
|
6
6
|
describe('Keys constant', () => {
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
|
-
import {
|
|
4
|
+
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Default MUI theme for testing
|