@openmrs/esm-react-utils 4.0.0-pre.1 → 4.0.1-pre.204

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.
@@ -5,7 +5,7 @@ import {
5
5
  ExtensionStore,
6
6
  getExtensionStore,
7
7
  } from "@openmrs/esm-extensions";
8
- import { isEqual } from "lodash";
8
+ import isEqual from "lodash/isEqual";
9
9
 
10
10
  /**
11
11
  * Gets the assigned extensions for a given extension slot name.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { render, cleanup, screen, waitFor } from "@testing-library/react";
2
+ import { render, cleanup, screen, waitFor, act } from "@testing-library/react";
3
3
  import {
4
4
  defineConfigSchema,
5
5
  temporaryConfigStore,
@@ -26,7 +26,6 @@ function clearConfig() {
26
26
 
27
27
  describe(`useConfig in root context`, () => {
28
28
  afterEach(clearConfig);
29
- afterEach(cleanup);
30
29
 
31
30
  it(`can return config as a react hook`, async () => {
32
31
  defineConfigSchema("foo-module", {
@@ -103,9 +102,11 @@ describe(`useConfig in root context`, () => {
103
102
  expect(screen.findByText("The first thing")).toBeTruthy()
104
103
  );
105
104
 
106
- temporaryConfigStore.setState({
107
- config: { "foo-module": { thing: "A new thing" } },
108
- });
105
+ act(() =>
106
+ temporaryConfigStore.setState({
107
+ config: { "foo-module": { thing: "A new thing" } },
108
+ })
109
+ );
109
110
 
110
111
  await waitFor(() => expect(screen.findByText("A new thing")).toBeTruthy());
111
112
  });
@@ -273,7 +274,7 @@ describe(`useConfig in an extension`, () => {
273
274
  );
274
275
 
275
276
  const newConfig = { "ext-module": { thing: "A new thing" } };
276
- temporaryConfigStore.setState({ config: newConfig });
277
+ act(() => temporaryConfigStore.setState({ config: newConfig }));
277
278
 
278
279
  await waitFor(() => expect(screen.findByText("A new thing")).toBeTruthy());
279
280
 
@@ -290,7 +291,7 @@ describe(`useConfig in an extension`, () => {
290
291
  },
291
292
  },
292
293
  };
293
- temporaryConfigStore.setState({ config: newConfig2 });
294
+ act(() => temporaryConfigStore.setState({ config: newConfig2 }));
294
295
 
295
296
  await waitFor(() =>
296
297
  expect(screen.findByText("Yet another thing")).toBeTruthy()
package/src/useConfig.ts CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  getConfigStore,
5
5
  getExtensionsConfigStore,
6
6
  ConfigStore,
7
+ ConfigObject,
7
8
  ExtensionsConfigStore,
8
9
  getExtensionConfigFromStore,
9
10
  } from "@openmrs/esm-config";
10
11
  import { ComponentContext, ExtensionData } from "./ComponentContext";
11
- import { ConfigObject } from "@openmrs/esm-config";
12
12
  import { Store } from "unistore";
13
13
  import isEqual from "lodash-es/isEqual";
14
14
 
@@ -1,2 +0,0 @@
1
- @openmrs/esm-react-utils:lint: cache hit, replaying output 79f18ce1ffc19bd2
2
- @openmrs/esm-react-utils:lint: $ eslint src
@@ -1,45 +0,0 @@
1
- @openmrs/esm-react-utils:test: cache hit, replaying output 5c98fc05f32d4ded
2
- @openmrs/esm-react-utils:test: $ jest --passWithNoTests
3
- @openmrs/esm-react-utils:test: PASS src/openmrsComponentDecorator.test.tsx (12.76 s)
4
- @openmrs/esm-react-utils:test: PASS src/useSession.test.tsx (14.355 s)
5
- @openmrs/esm-react-utils:test: PASS src/useOnClickOutside.test.tsx (14.227 s)
6
- @openmrs/esm-react-utils:test: PASS src/useConfig.test.tsx (16.25 s)
7
- @openmrs/esm-react-utils:test:  ● Console
8
- @openmrs/esm-react-utils:test: 
9
- @openmrs/esm-react-utils:test:  console.error
10
- @openmrs/esm-react-utils:test:  Warning: An update to RenderConfig inside a test was not wrapped in act(...).
11
- @openmrs/esm-react-utils:test: 
12
- @openmrs/esm-react-utils:test:  When testing, code that causes React state updates should be wrapped into act(...):
13
- @openmrs/esm-react-utils:test: 
14
- @openmrs/esm-react-utils:test:  act(() => {
15
- @openmrs/esm-react-utils:test:  /* fire events that update state */
16
- @openmrs/esm-react-utils:test:  });
17
- @openmrs/esm-react-utils:test:  /* assert on the output */
18
- @openmrs/esm-react-utils:test: 
19
- @openmrs/esm-react-utils:test:  This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
20
- @openmrs/esm-react-utils:test:  at RenderConfig (/home/brandon/Code/pih/mf/openmrs-esm-core/packages/framework/esm-react-utils/src/useConfig.test.tsx:18:29)
21
- @openmrs/esm-react-utils:test:  at Suspense
22
- @openmrs/esm-react-utils:test: 
23
- @openmrs/esm-react-utils:test:  85 | return store?.subscribe((state) => {
24
- @openmrs/esm-react-utils:test:  86 | if (state.loaded && state.config) {
25
- @openmrs/esm-react-utils:test:  > 87 | setState(state.config);
26
- @openmrs/esm-react-utils:test:  | ^
27
- @openmrs/esm-react-utils:test:  88 | }
28
- @openmrs/esm-react-utils:test:  89 | });
29
- @openmrs/esm-react-utils:test:  90 | }, [store]);
30
- @openmrs/esm-react-utils:test: 
31
- @openmrs/esm-react-utils:test:  at printWarning (../../../node_modules/react-dom/cjs/react-dom.development.js:86:30)
32
- @openmrs/esm-react-utils:test:  at error (../../../node_modules/react-dom/cjs/react-dom.development.js:60:7)
33
- @openmrs/esm-react-utils:test:  at warnIfUpdatesNotWrappedWithActDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:27543:9)
34
- @openmrs/esm-react-utils:test:  at scheduleUpdateOnFiber (../../../node_modules/react-dom/cjs/react-dom.development.js:25404:5)
35
- @openmrs/esm-react-utils:test:  at dispatchSetState (../../../node_modules/react-dom/cjs/react-dom.development.js:17389:16)
36
- @openmrs/esm-react-utils:test:  at Array.setState (src/useConfig.ts:87:9)
37
- @openmrs/esm-react-utils:test:  at Object.e (../../../node_modules/unistore/src/index.js:16:19)
38
- @openmrs/esm-react-utils:test: 
39
- @openmrs/esm-react-utils:test: PASS src/ConfigurableLink.test.tsx (17.386 s)
40
- @openmrs/esm-react-utils:test: 
41
- @openmrs/esm-react-utils:test: Test Suites: 5 passed, 5 total
42
- @openmrs/esm-react-utils:test: Tests: 19 passed, 19 total
43
- @openmrs/esm-react-utils:test: Snapshots: 0 total
44
- @openmrs/esm-react-utils:test: Time: 27.609 s
45
- @openmrs/esm-react-utils:test: Ran all test suites.