@trackunit/react-core-contexts-test 0.1.26 → 0.1.28

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.js CHANGED
@@ -1,4 +1,4 @@
1
- export { M as MockContextProviderBuilder, d as doNothing, f as flushPromises, b as flushPromisesInAct, m as mockCurrentUserContext, a as mockEnvironmentContext, q as queryFor, r as rootContext } from './index2.js';
1
+ export { M as MockContextProviderBuilder, d as doNothing, f as flushPromises, b as flushPromisesInAct, m as mockCurrentUserContext, a as mockEnvironmentContext, q as queryFor, r as rootContext, v as validateIrisApp } from './index2.js';
2
2
  import 'react/jsx-runtime';
3
3
  import '@testing-library/react';
4
4
  import '@trackunit/react-core-contexts-api';
package/index2.js CHANGED
@@ -369,4 +369,41 @@ const queryFor = (document, variables, data, error) => {
369
369
  };
370
370
  };
371
371
 
372
- export { MockContextProviderBuilder as M, __awaiter as _, mockEnvironmentContext as a, flushPromisesInAct as b, doNothing as d, flushPromises as f, mockCurrentUserContext as m, queryFor as q, rootContext as r };
372
+ /**
373
+ * This helps validate the IrisApp is exposed correctly it must expose:
374
+ * - bootstrap
375
+ * - mount
376
+ * - unmount
377
+ * According to the single spa spec.
378
+ *
379
+ * Your test could look like this
380
+ * @example
381
+ * import * as IrisApp from "./index";
382
+ describe("App", () => {
383
+ it("Should validate", async () => {
384
+ const result = await validateIrisApp(IrisApp);
385
+ expect(result).toBeNull();
386
+ });
387
+ });
388
+ *
389
+ * @param irisApp Import the index ts(x) file as above and pass it in.
390
+ * @returns null if everything is good - otherwise a string telling you what is wrong.
391
+ */
392
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
393
+ const validateIrisApp = (irisApp) => __awaiter(void 0, void 0, void 0, function* () {
394
+ if (!irisApp.bootstrap || typeof irisApp.bootstrap !== "function") {
395
+ return "Missing a bootstrap function";
396
+ }
397
+ if (!irisApp.mount || typeof irisApp.mount !== "function") {
398
+ return "Missing a mount function";
399
+ }
400
+ if (!irisApp.unmount || typeof irisApp.unmount !== "function") {
401
+ return "Missing an unmount function";
402
+ }
403
+ if (irisApp.update && typeof irisApp.update !== "function") {
404
+ return "Update must be a function";
405
+ }
406
+ return null;
407
+ });
408
+
409
+ export { MockContextProviderBuilder as M, __awaiter as _, mockEnvironmentContext as a, flushPromisesInAct as b, doNothing as d, flushPromises as f, mockCurrentUserContext as m, queryFor as q, rootContext as r, validateIrisApp as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "module": "./index.js",
@@ -11,7 +11,7 @@
11
11
  "@apollo/client": "3.6.9",
12
12
  "react": "18.2.0",
13
13
  "@trackunit/react-core-contexts-api": "0.2.14",
14
- "@trackunit/react-core-hooks": "0.2.25",
14
+ "@trackunit/react-core-hooks": "0.2.26",
15
15
  "@trackunit/tailwind-styled-components": "0.0.53",
16
16
  "react-router-dom": "6.4.5",
17
17
  "graphql": "15.8.0"
package/src/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from "./mocks/mockCurrentUserContext";
3
3
  export * from "./mocks/mockEnvironmentContext";
4
4
  export * from "./utils/doNothing";
5
5
  export * from "./utils/queryFor";
6
+ export * from "./utils/validateIrisApp";
6
7
  export * from "./utils/wait";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This helps validate the IrisApp is exposed correctly it must expose:
3
+ * - bootstrap
4
+ * - mount
5
+ * - unmount
6
+ * According to the single spa spec.
7
+ *
8
+ * Your test could look like this
9
+ * @example
10
+ * import * as IrisApp from "./index";
11
+ describe("App", () => {
12
+ it("Should validate", async () => {
13
+ const result = await validateIrisApp(IrisApp);
14
+ expect(result).toBeNull();
15
+ });
16
+ });
17
+ *
18
+ * @param irisApp Import the index ts(x) file as above and pass it in.
19
+ * @returns null if everything is good - otherwise a string telling you what is wrong.
20
+ */
21
+ export declare const validateIrisApp: (irisApp: any) => Promise<"Missing a bootstrap function" | "Missing a mount function" | "Missing an unmount function" | "Update must be a function" | null>;