@trackunit/react-core-contexts-test 0.1.56 → 0.1.57

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/HookRenderer.cjs CHANGED
@@ -20,7 +20,7 @@ require('graphql');
20
20
  *
21
21
  * @param callback The callback to render the hook.
22
22
  * @param getMockedCompositionRoot A function that will return the mocked composition root.
23
- * @returns The rendered hook.
23
+ * @returns { Promise<RenderHookResult> } The rendered hook.
24
24
  */
25
25
  const reactHooksRenderHook = (callback, getMockedCompositionRoot) => index.__awaiter(void 0, void 0, void 0, function* () {
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/HookRenderer.js CHANGED
@@ -18,7 +18,7 @@ import 'graphql';
18
18
  *
19
19
  * @param callback The callback to render the hook.
20
20
  * @param getMockedCompositionRoot A function that will return the mocked composition root.
21
- * @returns The rendered hook.
21
+ * @returns { Promise<RenderHookResult> } The rendered hook.
22
22
  */
23
23
  const reactHooksRenderHook = (callback, getMockedCompositionRoot) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/index.cjs CHANGED
@@ -21,6 +21,7 @@ exports.MockContextProviderBuilder = index.MockContextProviderBuilder;
21
21
  exports.doNothing = index.doNothing;
22
22
  exports.flushPromises = index.flushPromises;
23
23
  exports.flushPromisesInAct = index.flushPromisesInAct;
24
+ exports.mockAnalyticsContext = index.mockAnalyticsContext;
24
25
  exports.mockCurrentUserContext = index.mockCurrentUserContext;
25
26
  exports.mockEnvironmentContext = index.mockEnvironmentContext;
26
27
  exports.queryFor = index.queryFor;
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, u as useLogPropsChanged, v as validateIrisApp } from './index2.js';
1
+ export { M as MockContextProviderBuilder, d as doNothing, f as flushPromises, c as flushPromisesInAct, m as mockAnalyticsContext, a as mockCurrentUserContext, b as mockEnvironmentContext, q as queryFor, r as rootContext, u as useLogPropsChanged, 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.cjs CHANGED
@@ -93,6 +93,13 @@ const doNothing = () => {
93
93
  /* Do nothing */
94
94
  };
95
95
 
96
+ const mockAnalyticsContext = {
97
+ logEvent: doNothing,
98
+ logError: doNothing,
99
+ logPageView: doNothing,
100
+ setUserProperty: doNothing,
101
+ };
102
+
96
103
  const mockAssetSortingContext = {
97
104
  setSortBy: doNothing,
98
105
  sortingState: {
@@ -148,7 +155,7 @@ const mockToastContext = {
148
155
  *
149
156
  * @param features - array of features
150
157
  * @param packageType - package type
151
- * @returns IUserSubscriptionContext
158
+ * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
152
159
  */
153
160
  const mockUserSubscriptionProviderValue = (features, packageType) => {
154
161
  return {
@@ -217,11 +224,23 @@ class MockContextProviderBuilder {
217
224
  this.selectedGlobalSelection = { selection: null };
218
225
  this.selectedAssetSortingContext = mockAssetSortingContext;
219
226
  this.selectedCurrentUserContext = mockCurrentUserContext();
227
+ this.selectedAnalyticsContext = mockAnalyticsContext;
228
+ }
229
+ /**
230
+ * Use this Analytics Context.
231
+ *
232
+ * @param analyticsContext - The analytics context to use.
233
+ * @returns { MockContextProviderBuilder } - The builder.
234
+ */
235
+ analytics(analyticsContext) {
236
+ this.selectedAnalyticsContext = analyticsContext;
237
+ return this;
220
238
  }
221
239
  /**
222
240
  * Use this Environment Context.
223
241
  *
224
242
  * @param environmentContext - The environment context to use.
243
+ * @returns { MockContextProviderBuilder } - The builder.
225
244
  */
226
245
  environment(environmentContext) {
227
246
  this.selectedEnvironmentContext = environmentContext || mockEnvironmentContext;
@@ -231,6 +250,7 @@ class MockContextProviderBuilder {
231
250
  * Use this token.
232
251
  *
233
252
  * @param token - The token to use.
253
+ * @returns { MockContextProviderBuilder } - The builder.
234
254
  */
235
255
  token(token) {
236
256
  this.selectedTokenContext = { token };
@@ -238,6 +258,8 @@ class MockContextProviderBuilder {
238
258
  }
239
259
  /**
240
260
  * User this to pass in a differerent current user.
261
+ *
262
+ * @returns { MockContextProviderBuilder } - The builder.
241
263
  */
242
264
  currentUser(currentUserContext) {
243
265
  this.selectedCurrentUserContext = currentUserContext;
@@ -247,6 +269,7 @@ class MockContextProviderBuilder {
247
269
  * Use this to pass in userSubscriptionPackage.
248
270
  *
249
271
  * @param userSubscriptionPackage - The developer settings context to use.
272
+ * @returns { MockContextProviderBuilder } - The builder.
250
273
  */
251
274
  userSubscriptionPackage(userSubscriptionPackage) {
252
275
  if (userSubscriptionPackage) {
@@ -258,6 +281,7 @@ class MockContextProviderBuilder {
258
281
  * Use this to pass in SupportedFeatures.
259
282
  *
260
283
  * @param features - The developer settings context to use.
284
+ * @returns { MockContextProviderBuilder } - The builder.
261
285
  */
262
286
  supportedFeatures(features) {
263
287
  if (features) {
@@ -274,6 +298,7 @@ class MockContextProviderBuilder {
274
298
  * Use this Router Props with the given mocks.
275
299
  *
276
300
  * @param routerProps - The router props to use.
301
+ * @returns { MockContextProviderBuilder } - The builder.
277
302
  */
278
303
  routerProps(routerProps) {
279
304
  this.selectedRouterProps = routerProps || {};
@@ -283,6 +308,7 @@ class MockContextProviderBuilder {
283
308
  * Use this global selection.
284
309
  *
285
310
  * @param globalSelection - The global selection to use.
311
+ * @returns { MockContextProviderBuilder } - The builder.
286
312
  */
287
313
  globalSelection(globalSelection) {
288
314
  this.selectedGlobalSelection = { selection: globalSelection };
@@ -292,6 +318,7 @@ class MockContextProviderBuilder {
292
318
  * Set global asset sorting context.
293
319
  *
294
320
  * @param overrides - Override the default context.
321
+ * @returns { MockContextProviderBuilder } - The builder.
295
322
  */
296
323
  assetSorting(overrides) {
297
324
  this.selectedAssetSortingContext = Object.assign(Object.assign({}, mockAssetSortingContext), overrides);
@@ -354,7 +381,7 @@ class MockContextProviderBuilder {
354
381
  * Validate the mocks that has been supplied to make sure they make sense.
355
382
  * Note: This function is overriden in builders extending this one.
356
383
  *
357
- * @returns true or throws error if any invalid mocks
384
+ * @returns {boolean} true or throws error if any invalid mocks
358
385
  */
359
386
  validateSuppliedMocks() {
360
387
  return true;
@@ -366,7 +393,7 @@ class MockContextProviderBuilder {
366
393
  * @param addTestRootContainer - if you want to add a root container to the test.
367
394
  */
368
395
  getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
369
- return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsxRuntime.jsx(reactCoreHooks.GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsxRuntime.jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsxRuntime.jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsxRuntime.jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })));
396
+ return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsxRuntime.jsx(reactCoreHooks.GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsxRuntime.jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsxRuntime.jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsxRuntime.jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })));
370
397
  }
371
398
  }
372
399
  /**
@@ -403,6 +430,7 @@ const useLogPropsChanged = (propsToWatch) => {
403
430
  if (Object.keys(changedProps).length > 0) {
404
431
  // eslint-disable-next-line no-console
405
432
  Object.keys(changedProps).forEach(changedProp => {
433
+ // eslint-disable-next-line no-console
406
434
  console.log("Props changed:", changedProp, parentCaller);
407
435
  // JSON stringify is used to avoid console.table from logging the object reference
408
436
  const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
@@ -416,8 +444,10 @@ const useLogPropsChanged = (propsToWatch) => {
416
444
  Object.keys(result1).forEach(prop => {
417
445
  result1[prop] = JSON.stringify(result1[prop]);
418
446
  });
447
+ // eslint-disable-next-line no-console
419
448
  console.table([result0, result1]);
420
449
  });
450
+ // eslint-disable-next-line no-console
421
451
  console.dir(changedProps);
422
452
  }
423
453
  prevPropsRef.current = propsToWatch;
@@ -508,6 +538,7 @@ exports.__awaiter = __awaiter;
508
538
  exports.doNothing = doNothing;
509
539
  exports.flushPromises = flushPromises;
510
540
  exports.flushPromisesInAct = flushPromisesInAct;
541
+ exports.mockAnalyticsContext = mockAnalyticsContext;
511
542
  exports.mockCurrentUserContext = mockCurrentUserContext;
512
543
  exports.mockEnvironmentContext = mockEnvironmentContext;
513
544
  exports.queryFor = queryFor;
package/index2.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { act, render } from '@testing-library/react';
3
3
  import { AssetSortByProperty, SortOrder, UserSubscriptionPackage } from '@trackunit/react-core-contexts-api';
4
- import { EnvironmentContextProvider, CurrentUserProvider, UserSubscriptionProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, AssetSortingProvider } from '@trackunit/react-core-hooks';
4
+ import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, AssetSortingProvider } from '@trackunit/react-core-hooks';
5
5
  import { tw } from '@trackunit/tailwind-styled-components';
6
6
  import { MemoryRouter } from 'react-router-dom';
7
7
  import { ApolloLink } from '@apollo/client';
@@ -91,6 +91,13 @@ const doNothing = () => {
91
91
  /* Do nothing */
92
92
  };
93
93
 
94
+ const mockAnalyticsContext = {
95
+ logEvent: doNothing,
96
+ logError: doNothing,
97
+ logPageView: doNothing,
98
+ setUserProperty: doNothing,
99
+ };
100
+
94
101
  const mockAssetSortingContext = {
95
102
  setSortBy: doNothing,
96
103
  sortingState: {
@@ -146,7 +153,7 @@ const mockToastContext = {
146
153
  *
147
154
  * @param features - array of features
148
155
  * @param packageType - package type
149
- * @returns IUserSubscriptionContext
156
+ * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
150
157
  */
151
158
  const mockUserSubscriptionProviderValue = (features, packageType) => {
152
159
  return {
@@ -215,11 +222,23 @@ class MockContextProviderBuilder {
215
222
  this.selectedGlobalSelection = { selection: null };
216
223
  this.selectedAssetSortingContext = mockAssetSortingContext;
217
224
  this.selectedCurrentUserContext = mockCurrentUserContext();
225
+ this.selectedAnalyticsContext = mockAnalyticsContext;
226
+ }
227
+ /**
228
+ * Use this Analytics Context.
229
+ *
230
+ * @param analyticsContext - The analytics context to use.
231
+ * @returns { MockContextProviderBuilder } - The builder.
232
+ */
233
+ analytics(analyticsContext) {
234
+ this.selectedAnalyticsContext = analyticsContext;
235
+ return this;
218
236
  }
219
237
  /**
220
238
  * Use this Environment Context.
221
239
  *
222
240
  * @param environmentContext - The environment context to use.
241
+ * @returns { MockContextProviderBuilder } - The builder.
223
242
  */
224
243
  environment(environmentContext) {
225
244
  this.selectedEnvironmentContext = environmentContext || mockEnvironmentContext;
@@ -229,6 +248,7 @@ class MockContextProviderBuilder {
229
248
  * Use this token.
230
249
  *
231
250
  * @param token - The token to use.
251
+ * @returns { MockContextProviderBuilder } - The builder.
232
252
  */
233
253
  token(token) {
234
254
  this.selectedTokenContext = { token };
@@ -236,6 +256,8 @@ class MockContextProviderBuilder {
236
256
  }
237
257
  /**
238
258
  * User this to pass in a differerent current user.
259
+ *
260
+ * @returns { MockContextProviderBuilder } - The builder.
239
261
  */
240
262
  currentUser(currentUserContext) {
241
263
  this.selectedCurrentUserContext = currentUserContext;
@@ -245,6 +267,7 @@ class MockContextProviderBuilder {
245
267
  * Use this to pass in userSubscriptionPackage.
246
268
  *
247
269
  * @param userSubscriptionPackage - The developer settings context to use.
270
+ * @returns { MockContextProviderBuilder } - The builder.
248
271
  */
249
272
  userSubscriptionPackage(userSubscriptionPackage) {
250
273
  if (userSubscriptionPackage) {
@@ -256,6 +279,7 @@ class MockContextProviderBuilder {
256
279
  * Use this to pass in SupportedFeatures.
257
280
  *
258
281
  * @param features - The developer settings context to use.
282
+ * @returns { MockContextProviderBuilder } - The builder.
259
283
  */
260
284
  supportedFeatures(features) {
261
285
  if (features) {
@@ -272,6 +296,7 @@ class MockContextProviderBuilder {
272
296
  * Use this Router Props with the given mocks.
273
297
  *
274
298
  * @param routerProps - The router props to use.
299
+ * @returns { MockContextProviderBuilder } - The builder.
275
300
  */
276
301
  routerProps(routerProps) {
277
302
  this.selectedRouterProps = routerProps || {};
@@ -281,6 +306,7 @@ class MockContextProviderBuilder {
281
306
  * Use this global selection.
282
307
  *
283
308
  * @param globalSelection - The global selection to use.
309
+ * @returns { MockContextProviderBuilder } - The builder.
284
310
  */
285
311
  globalSelection(globalSelection) {
286
312
  this.selectedGlobalSelection = { selection: globalSelection };
@@ -290,6 +316,7 @@ class MockContextProviderBuilder {
290
316
  * Set global asset sorting context.
291
317
  *
292
318
  * @param overrides - Override the default context.
319
+ * @returns { MockContextProviderBuilder } - The builder.
293
320
  */
294
321
  assetSorting(overrides) {
295
322
  this.selectedAssetSortingContext = Object.assign(Object.assign({}, mockAssetSortingContext), overrides);
@@ -352,7 +379,7 @@ class MockContextProviderBuilder {
352
379
  * Validate the mocks that has been supplied to make sure they make sense.
353
380
  * Note: This function is overriden in builders extending this one.
354
381
  *
355
- * @returns true or throws error if any invalid mocks
382
+ * @returns {boolean} true or throws error if any invalid mocks
356
383
  */
357
384
  validateSuppliedMocks() {
358
385
  return true;
@@ -364,7 +391,7 @@ class MockContextProviderBuilder {
364
391
  * @param addTestRootContainer - if you want to add a root container to the test.
365
392
  */
366
393
  getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
367
- return (jsx(EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsx(CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsx(UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsx(TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsx(ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsx(GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsx(AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })));
394
+ return (jsx(EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsx(CurrentUserProvider, Object.assign({ value: this.selectedCurrentUserContext }, { children: jsx(AnalyticsContext.Provider, Object.assign({ value: this.selectedAnalyticsContext }, { children: jsx(UserSubscriptionProvider, Object.assign({ value: mockUserSubscriptionProviderValue(this.features, this.userSubscriptionPackageType) }, { children: jsx(TokenProvider, Object.assign({ value: this.selectedTokenContext }, { children: jsx(ToastProvider, Object.assign({ value: this.selectedToastContext }, { children: jsx(GlobalSelectionProvider, Object.assign({ value: this.selectedGlobalSelection }, { children: jsx(AssetSortingProvider, Object.assign({ value: this.selectedAssetSortingContext }, { children: jsx(ApolloMockedProviderWithError, Object.assign({ mocks: this.selectedApolloMocks, addTypename: false }, { children: addTestRootContainer ? (jsx(TestRoot, Object.assign({ "data-testid": "testRoot" }, { children: testChildren }))) : (jsx("div", { children: testChildren })) })) })) })) })) })) })) })) })) })) })));
368
395
  }
369
396
  }
370
397
  /**
@@ -401,6 +428,7 @@ const useLogPropsChanged = (propsToWatch) => {
401
428
  if (Object.keys(changedProps).length > 0) {
402
429
  // eslint-disable-next-line no-console
403
430
  Object.keys(changedProps).forEach(changedProp => {
431
+ // eslint-disable-next-line no-console
404
432
  console.log("Props changed:", changedProp, parentCaller);
405
433
  // JSON stringify is used to avoid console.table from logging the object reference
406
434
  const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
@@ -414,8 +442,10 @@ const useLogPropsChanged = (propsToWatch) => {
414
442
  Object.keys(result1).forEach(prop => {
415
443
  result1[prop] = JSON.stringify(result1[prop]);
416
444
  });
445
+ // eslint-disable-next-line no-console
417
446
  console.table([result0, result1]);
418
447
  });
448
+ // eslint-disable-next-line no-console
419
449
  console.dir(changedProps);
420
450
  }
421
451
  prevPropsRef.current = propsToWatch;
@@ -501,4 +531,4 @@ const validateIrisApp = (irisApp) => __awaiter(void 0, void 0, void 0, function*
501
531
  return null;
502
532
  });
503
533
 
504
- 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, useLogPropsChanged as u, validateIrisApp as v };
534
+ export { MockContextProviderBuilder as M, __awaiter as _, mockCurrentUserContext as a, mockEnvironmentContext as b, flushPromisesInAct as c, doNothing as d, flushPromises as f, mockAnalyticsContext as m, queryFor as q, rootContext as r, useLogPropsChanged as u, 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.56",
3
+ "version": "0.1.57",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "module": "./index.js",
@@ -9,8 +9,8 @@
9
9
  "types": "./src/index.d.ts",
10
10
  "dependencies": {
11
11
  "@apollo/client": "3.7.10",
12
- "@trackunit/react-core-contexts-api": "0.2.29",
13
- "@trackunit/react-core-hooks": "0.2.51",
12
+ "@trackunit/react-core-contexts-api": "0.2.30",
13
+ "@trackunit/react-core-hooks": "0.2.52",
14
14
  "@trackunit/tailwind-styled-components": "0.0.56",
15
15
  "graphql": "15.8.0",
16
16
  "react": "18.2.0",
@@ -6,6 +6,6 @@ import * as React from "react";
6
6
  *
7
7
  * @param callback The callback to render the hook.
8
8
  * @param getMockedCompositionRoot A function that will return the mocked composition root.
9
- * @returns The rendered hook.
9
+ * @returns { Promise<RenderHookResult> } The rendered hook.
10
10
  */
11
11
  export declare const reactHooksRenderHook: <TProps, TResult>(callback: (props: TProps) => TResult, getMockedCompositionRoot: (children: React.ReactElement) => React.ReactElement) => Promise<RenderHookResult<TResult, TProps>>;
@@ -1,6 +1,6 @@
1
1
  import { MockedResponse } from "@apollo/client/testing";
2
2
  import { RenderResult } from "@testing-library/react";
3
- import { IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IFeature, IGlobalSelectionContext, IToastContext, ITokenContext, UserSubscriptionPackageType } from "@trackunit/react-core-contexts-api";
3
+ import { IAnalyticsContext, IAssetSortingContext, ICurrentUserContext, IEnvironmentContext, IFeature, IGlobalSelectionContext, IToastContext, ITokenContext, UserSubscriptionPackageType } from "@trackunit/react-core-contexts-api";
4
4
  import * as React from "react";
5
5
  import { MemoryRouterProps } from "react-router-dom";
6
6
  /**
@@ -19,50 +19,67 @@ export declare class MockContextProviderBuilder {
19
19
  protected selectedGlobalSelection: IGlobalSelectionContext;
20
20
  protected selectedAssetSortingContext: IAssetSortingContext;
21
21
  protected selectedCurrentUserContext: ICurrentUserContext;
22
+ protected selectedAnalyticsContext: IAnalyticsContext<{}>;
23
+ /**
24
+ * Use this Analytics Context.
25
+ *
26
+ * @param analyticsContext - The analytics context to use.
27
+ * @returns { MockContextProviderBuilder } - The builder.
28
+ */
29
+ analytics(analyticsContext: IAnalyticsContext<{}>): this;
22
30
  /**
23
31
  * Use this Environment Context.
24
32
  *
25
33
  * @param environmentContext - The environment context to use.
34
+ * @returns { MockContextProviderBuilder } - The builder.
26
35
  */
27
36
  environment(environmentContext?: IEnvironmentContext): this;
28
37
  /**
29
38
  * Use this token.
30
39
  *
31
40
  * @param token - The token to use.
41
+ * @returns { MockContextProviderBuilder } - The builder.
32
42
  */
33
43
  token(token: string): this;
34
44
  /**
35
45
  * User this to pass in a differerent current user.
46
+ *
47
+ * @returns { MockContextProviderBuilder } - The builder.
36
48
  */
37
49
  currentUser(currentUserContext: ICurrentUserContext): this;
38
50
  /**
39
51
  * Use this to pass in userSubscriptionPackage.
40
52
  *
41
53
  * @param userSubscriptionPackage - The developer settings context to use.
54
+ * @returns { MockContextProviderBuilder } - The builder.
42
55
  */
43
56
  userSubscriptionPackage(userSubscriptionPackage?: UserSubscriptionPackageType): this;
44
57
  /**
45
58
  * Use this to pass in SupportedFeatures.
46
59
  *
47
60
  * @param features - The developer settings context to use.
61
+ * @returns { MockContextProviderBuilder } - The builder.
48
62
  */
49
63
  supportedFeatures(features?: string[]): this;
50
64
  /**
51
65
  * Use this Router Props with the given mocks.
52
66
  *
53
67
  * @param routerProps - The router props to use.
68
+ * @returns { MockContextProviderBuilder } - The builder.
54
69
  */
55
70
  routerProps(routerProps?: MemoryRouterProps): this;
56
71
  /**
57
72
  * Use this global selection.
58
73
  *
59
74
  * @param globalSelection - The global selection to use.
75
+ * @returns { MockContextProviderBuilder } - The builder.
60
76
  */
61
77
  globalSelection(globalSelection: IGlobalSelectionContext["selection"]): this;
62
78
  /**
63
79
  * Set global asset sorting context.
64
80
  *
65
81
  * @param overrides - Override the default context.
82
+ * @returns { MockContextProviderBuilder } - The builder.
66
83
  */
67
84
  assetSorting(overrides: Partial<IAssetSortingContext>): this;
68
85
  /**
@@ -91,7 +108,7 @@ export declare class MockContextProviderBuilder {
91
108
  * Validate the mocks that has been supplied to make sure they make sense.
92
109
  * Note: This function is overriden in builders extending this one.
93
110
  *
94
- * @returns true or throws error if any invalid mocks
111
+ * @returns {boolean} true or throws error if any invalid mocks
95
112
  */
96
113
  protected validateSuppliedMocks(): true | never;
97
114
  /**
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./MockContextProviderBuilder";
2
+ export * from "./mocks/mockAnalyticsContext";
2
3
  export * from "./mocks/mockCurrentUserContext";
3
4
  export * from "./mocks/mockEnvironmentContext";
4
5
  export * from "./useLogPropsChanged";
@@ -0,0 +1,2 @@
1
+ import { IAnalyticsContext } from "@trackunit/react-core-contexts-api";
2
+ export declare const mockAnalyticsContext: IAnalyticsContext<{}>;
@@ -4,6 +4,6 @@ import { IFeature, IUserSubscriptionContext, UserSubscriptionPackageType } from
4
4
  *
5
5
  * @param features - array of features
6
6
  * @param packageType - package type
7
- * @returns IUserSubscriptionContext
7
+ * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
8
8
  */
9
9
  export declare const mockUserSubscriptionProviderValue: (features: IFeature[], packageType: UserSubscriptionPackageType) => IUserSubscriptionContext;