@tramvai/test-react 2.22.0 → 2.24.3

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Set of helpers for testing React-components
4
4
 
5
- Helpers are based on libraries [@testing-library/react](https://github.com/testing-library/react-testing-library) [@testing-library/react-hooks](https://github.com/testing-library/react-hooks-testing-library)
5
+ Helpers are based on libraries [@testing-library/react](https://github.com/testing-library/react-testing-library)
6
6
 
7
7
  If you are using jest for testing, consider to add a library [@testing-library/jest-dom](https://github.com/testing-library/jest-dom)
8
8
 
@@ -74,7 +74,7 @@ describe('test', () => {
74
74
 
75
75
  ### Test React-hooks
76
76
 
77
- Under the hood the [@testing-library/react-hooks](https://github.com/testing-library/react-hooks-testing-library) is used.
77
+ Under the hood the [@testing-library/react](https://github.com/testing-library/react-testing-library) is used.
78
78
 
79
79
  ```ts
80
80
  /**
package/lib/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { render, act, fireEvent } from '@testing-library/react';
1
+ import { render, act, fireEvent, renderHook } from '@testing-library/react';
2
2
  export * from '@testing-library/react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
  import { Provider } from '@tramvai/state';
@@ -6,7 +6,6 @@ import { DIContext } from '@tramvai/react';
6
6
  import { Provider as Provider$1 } from '@tinkoff/router';
7
7
  import { createMockContext, createMockRouter } from '@tramvai/test-mocks';
8
8
  import { waitRaf } from '@tramvai/test-jsdom';
9
- import { renderHook, act as act$1 } from '@testing-library/react-hooks';
10
9
 
11
10
  const testComponent = (element, { providers, initialState, store, stores, di, context = createMockContext({ initialState, providers, di, store, stores }), currentRoute, currentUrl, router = createMockRouter({ currentRoute, currentUrl }), renderOptions, } = {}) => {
12
11
  const Wrapper = ({ children }) => (jsx(Provider, Object.assign({ context: context, serverState: initialState }, { children: jsx(DIContext.Provider, Object.assign({ value: context.di }, { children: jsx(Provider$1, Object.assign({ router: router, serverState: initialState === null || initialState === void 0 ? void 0 : initialState.router }, { children: children }), void 0) }), void 0) }), void 0));
@@ -42,7 +41,7 @@ const testHook = (hookCallback, { providers, initialState, store, stores, di, co
42
41
  return {
43
42
  result,
44
43
  rerender,
45
- act: act$1,
44
+ act,
46
45
  context,
47
46
  router,
48
47
  };
package/lib/index.js CHANGED
@@ -9,7 +9,6 @@ var react$1 = require('@tramvai/react');
9
9
  var router = require('@tinkoff/router');
10
10
  var testMocks = require('@tramvai/test-mocks');
11
11
  var testJsdom = require('@tramvai/test-jsdom');
12
- var reactHooks = require('@testing-library/react-hooks');
13
12
 
14
13
  const testComponent = (element, { providers, initialState, store, stores, di, context = testMocks.createMockContext({ initialState, providers, di, store, stores }), currentRoute, currentUrl, router: router$1 = testMocks.createMockRouter({ currentRoute, currentUrl }), renderOptions, } = {}) => {
15
14
  const Wrapper = ({ children }) => (jsxRuntime.jsx(state.Provider, Object.assign({ context: context, serverState: initialState }, { children: jsxRuntime.jsx(react$1.DIContext.Provider, Object.assign({ value: context.di }, { children: jsxRuntime.jsx(router.Provider, Object.assign({ router: router$1, serverState: initialState === null || initialState === void 0 ? void 0 : initialState.router }, { children: children }), void 0) }), void 0) }), void 0));
@@ -36,7 +35,7 @@ const testComponent = (element, { providers, initialState, store, stores, di, co
36
35
  const testHook = (hookCallback, { providers, initialState, store, stores, di, context = testMocks.createMockContext({ initialState, providers, di, store, stores }), currentRoute, currentUrl, router: router$1 = testMocks.createMockRouter({ currentRoute, currentUrl }), renderOptions, } = {}) => {
37
36
  var _a;
38
37
  const Wrapper = (_a = renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.wrapper) !== null && _a !== void 0 ? _a : (({ children }) => children);
39
- const { result, rerender } = reactHooks.renderHook(hookCallback, {
38
+ const { result, rerender } = react.renderHook(hookCallback, {
40
39
  ...renderOptions,
41
40
  wrapper: ({ children }) => {
42
41
  return (jsxRuntime.jsx(state.Provider, Object.assign({ context: context, serverState: initialState }, { children: jsxRuntime.jsx(react$1.DIContext.Provider, Object.assign({ value: context.di }, { children: jsxRuntime.jsx(router.Provider, Object.assign({ router: router$1, serverState: initialState === null || initialState === void 0 ? void 0 : initialState.router }, { children: jsxRuntime.jsx(Wrapper, { children: children }, void 0) }), void 0) }), void 0) }), void 0));
@@ -45,7 +44,7 @@ const testHook = (hookCallback, { providers, initialState, store, stores, di, co
45
44
  return {
46
45
  result,
47
46
  rerender,
48
- act: reactHooks.act,
47
+ act: react.act,
49
48
  context,
50
49
  router: router$1,
51
50
  };
package/lib/testHook.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RenderHookOptions } from '@testing-library/react-hooks';
1
+ import type { RenderHookOptions } from '@testing-library/react';
2
2
  import type { CONTEXT_TOKEN } from '@tramvai/tokens-common';
3
3
  import type { AbstractRouter } from '@tinkoff/router';
4
4
  import type { createMockDi } from '@tramvai/test-mocks';
@@ -12,9 +12,11 @@ declare type Options = OptionsDi & OptionsContext & OptionsRouter & {
12
12
  renderOptions?: RenderHookOptions<any>;
13
13
  };
14
14
  export declare const testHook: <TProps, TResult>(hookCallback: (props: TProps) => TResult, { providers, initialState, store, stores, di, context, currentRoute, currentUrl, router, renderOptions, }?: Options) => {
15
- result: import("@testing-library/react-hooks").RenderResult<TResult>;
15
+ result: {
16
+ current: TResult;
17
+ };
16
18
  rerender: (props?: TProps | undefined) => void;
17
- act: import("@testing-library/react-hooks").Act;
19
+ act: typeof import("react-dom/test-utils").act;
18
20
  context: import("@tinkoff/dippy").BaseTokenInterface<import("@tramvai/tokens-common").ConsumerContext>;
19
21
  router: AbstractRouter;
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/test-react",
3
- "version": "2.22.0",
3
+ "version": "2.24.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -18,14 +18,13 @@
18
18
  "build-for-publish": "true"
19
19
  },
20
20
  "dependencies": {
21
- "@testing-library/react": "^12.1.4",
22
- "@testing-library/react-hooks": "^7.0.2",
21
+ "@testing-library/react": "^13.3.0",
23
22
  "@tinkoff/router": "0.2.2",
24
- "@tramvai/react": "2.22.0",
25
- "@tramvai/state": "2.22.0",
26
- "@tramvai/test-jsdom": "2.22.0",
27
- "@tramvai/test-mocks": "2.22.0",
28
- "@tramvai/tokens-common": "2.22.0",
23
+ "@tramvai/react": "2.24.3",
24
+ "@tramvai/state": "2.24.3",
25
+ "@tramvai/test-jsdom": "2.24.3",
26
+ "@tramvai/test-mocks": "2.24.3",
27
+ "@tramvai/tokens-common": "2.24.3",
29
28
  "tslib": "^2.0.3"
30
29
  },
31
30
  "peerDependencies": {