@trackunit/react-core-contexts-test 0.1.47-alpha-47c0e3bbca.0 → 0.1.47
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/index2.cjs +10 -12
- package/index2.js +10 -12
- package/package.json +4 -4
- package/src/MockContextProviderBuilder.d.ts +5 -7
package/index2.cjs
CHANGED
|
@@ -106,7 +106,7 @@ const mockAssetSortingContext = {
|
|
|
106
106
|
* @param overrides - The overrides to apply to the mock
|
|
107
107
|
* @returns {ICurrentUserContext} - Returns the mocked current user context
|
|
108
108
|
*/
|
|
109
|
-
const mockCurrentUserContext = (overrides = {}) => (Object.assign({ userName: "", userRole: "", customerId: 12345, userId: 154312, tasUserId: "751ea227-f199-4d00-925f-a608312c5e45", email: "", name: "", accountId: "", assumedUser: null, jobTitle: "", isAuthenticated: true, isVerified: true, isAccountOwner: true, subscriptionPackage: "EXPAND_FLEET_OWNER" }, overrides));
|
|
109
|
+
const mockCurrentUserContext = (overrides = {}) => (Object.assign({ userName: "", userRole: "", customerId: 12345, userId: 154312, tasUserId: "751ea227-f199-4d00-925f-a608312c5e45", email: "", name: "", accountId: "", assumedUser: null, jobTitle: "", isAuthenticated: true, isVerified: true, isTrackunitUser: false, isAssuming: false, isAccountOwner: true, subscriptionPackage: "EXPAND_FLEET_OWNER" }, overrides));
|
|
110
110
|
|
|
111
111
|
const mockEnvironmentContext = {
|
|
112
112
|
auth: {
|
|
@@ -213,9 +213,9 @@ class MockContextProviderBuilder {
|
|
|
213
213
|
this.selectedApolloMocks = [];
|
|
214
214
|
this.selectedRouterProps = {};
|
|
215
215
|
this.selectedToastContext = mockToastContext;
|
|
216
|
-
this.selectedAssumedUser = mockCurrentUserContext().assumedUser;
|
|
217
216
|
this.selectedGlobalSelection = { selection: null };
|
|
218
217
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
218
|
+
this.selectedCurrentUserContext = mockCurrentUserContext();
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* Use this Environment Context.
|
|
@@ -235,6 +235,13 @@ class MockContextProviderBuilder {
|
|
|
235
235
|
this.selectedTokenContext = { token };
|
|
236
236
|
return this;
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* User this to pass in a differerent current user.
|
|
240
|
+
*/
|
|
241
|
+
currentUser(currentUserContext) {
|
|
242
|
+
this.selectedCurrentUserContext = currentUserContext;
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
238
245
|
/**
|
|
239
246
|
* Use this to pass in userSubscriptionPackage.
|
|
240
247
|
*
|
|
@@ -262,15 +269,6 @@ class MockContextProviderBuilder {
|
|
|
262
269
|
}
|
|
263
270
|
return this;
|
|
264
271
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Assume this user
|
|
267
|
-
*
|
|
268
|
-
* @param assumeUser - The user to assume.
|
|
269
|
-
*/
|
|
270
|
-
assumeUser(assumeUser) {
|
|
271
|
-
this.selectedAssumedUser = assumeUser;
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
272
|
/**
|
|
275
273
|
* Use this Router Props with the given mocks.
|
|
276
274
|
*
|
|
@@ -367,7 +365,7 @@ class MockContextProviderBuilder {
|
|
|
367
365
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
368
366
|
*/
|
|
369
367
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
370
|
-
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:
|
|
368
|
+
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 })) })) })) })) })) })) })) })) })) })));
|
|
371
369
|
}
|
|
372
370
|
}
|
|
373
371
|
/**
|
package/index2.js
CHANGED
|
@@ -104,7 +104,7 @@ const mockAssetSortingContext = {
|
|
|
104
104
|
* @param overrides - The overrides to apply to the mock
|
|
105
105
|
* @returns {ICurrentUserContext} - Returns the mocked current user context
|
|
106
106
|
*/
|
|
107
|
-
const mockCurrentUserContext = (overrides = {}) => (Object.assign({ userName: "", userRole: "", customerId: 12345, userId: 154312, tasUserId: "751ea227-f199-4d00-925f-a608312c5e45", email: "", name: "", accountId: "", assumedUser: null, jobTitle: "", isAuthenticated: true, isVerified: true, isAccountOwner: true, subscriptionPackage: "EXPAND_FLEET_OWNER" }, overrides));
|
|
107
|
+
const mockCurrentUserContext = (overrides = {}) => (Object.assign({ userName: "", userRole: "", customerId: 12345, userId: 154312, tasUserId: "751ea227-f199-4d00-925f-a608312c5e45", email: "", name: "", accountId: "", assumedUser: null, jobTitle: "", isAuthenticated: true, isVerified: true, isTrackunitUser: false, isAssuming: false, isAccountOwner: true, subscriptionPackage: "EXPAND_FLEET_OWNER" }, overrides));
|
|
108
108
|
|
|
109
109
|
const mockEnvironmentContext = {
|
|
110
110
|
auth: {
|
|
@@ -211,9 +211,9 @@ class MockContextProviderBuilder {
|
|
|
211
211
|
this.selectedApolloMocks = [];
|
|
212
212
|
this.selectedRouterProps = {};
|
|
213
213
|
this.selectedToastContext = mockToastContext;
|
|
214
|
-
this.selectedAssumedUser = mockCurrentUserContext().assumedUser;
|
|
215
214
|
this.selectedGlobalSelection = { selection: null };
|
|
216
215
|
this.selectedAssetSortingContext = mockAssetSortingContext;
|
|
216
|
+
this.selectedCurrentUserContext = mockCurrentUserContext();
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Use this Environment Context.
|
|
@@ -233,6 +233,13 @@ class MockContextProviderBuilder {
|
|
|
233
233
|
this.selectedTokenContext = { token };
|
|
234
234
|
return this;
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* User this to pass in a differerent current user.
|
|
238
|
+
*/
|
|
239
|
+
currentUser(currentUserContext) {
|
|
240
|
+
this.selectedCurrentUserContext = currentUserContext;
|
|
241
|
+
return this;
|
|
242
|
+
}
|
|
236
243
|
/**
|
|
237
244
|
* Use this to pass in userSubscriptionPackage.
|
|
238
245
|
*
|
|
@@ -260,15 +267,6 @@ class MockContextProviderBuilder {
|
|
|
260
267
|
}
|
|
261
268
|
return this;
|
|
262
269
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Assume this user
|
|
265
|
-
*
|
|
266
|
-
* @param assumeUser - The user to assume.
|
|
267
|
-
*/
|
|
268
|
-
assumeUser(assumeUser) {
|
|
269
|
-
this.selectedAssumedUser = assumeUser;
|
|
270
|
-
return this;
|
|
271
|
-
}
|
|
272
270
|
/**
|
|
273
271
|
* Use this Router Props with the given mocks.
|
|
274
272
|
*
|
|
@@ -365,7 +363,7 @@ class MockContextProviderBuilder {
|
|
|
365
363
|
* @param addTestRootContainer - if you want to add a root container to the test.
|
|
366
364
|
*/
|
|
367
365
|
getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
|
|
368
|
-
return (jsx(EnvironmentContextProvider, Object.assign({ value: this.selectedEnvironmentContext }, { children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsx(CurrentUserProvider, Object.assign({ value:
|
|
366
|
+
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 })) })) })) })) })) })) })) })) })) })));
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
369
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts-test",
|
|
3
|
-
"version": "0.1.47
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
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.25
|
|
13
|
-
"@trackunit/react-core-hooks": "0.2.43
|
|
14
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
12
|
+
"@trackunit/react-core-contexts-api": "0.2.25",
|
|
13
|
+
"@trackunit/react-core-hooks": "0.2.43",
|
|
14
|
+
"@trackunit/tailwind-styled-components": "0.0.55",
|
|
15
15
|
"graphql": "15.8.0",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"react-router-dom": "6.4.5"
|
|
@@ -16,9 +16,9 @@ export declare class MockContextProviderBuilder {
|
|
|
16
16
|
protected selectedApolloMocks: MockedResponse[];
|
|
17
17
|
protected selectedRouterProps: MemoryRouterProps;
|
|
18
18
|
protected selectedToastContext: IToastContext;
|
|
19
|
-
protected selectedAssumedUser: ICurrentUserContext["assumedUser"];
|
|
20
19
|
protected selectedGlobalSelection: IGlobalSelectionContext;
|
|
21
20
|
protected selectedAssetSortingContext: IAssetSortingContext;
|
|
21
|
+
protected selectedCurrentUserContext: ICurrentUserContext;
|
|
22
22
|
/**
|
|
23
23
|
* Use this Environment Context.
|
|
24
24
|
*
|
|
@@ -31,6 +31,10 @@ export declare class MockContextProviderBuilder {
|
|
|
31
31
|
* @param token - The token to use.
|
|
32
32
|
*/
|
|
33
33
|
token(token: string): this;
|
|
34
|
+
/**
|
|
35
|
+
* User this to pass in a differerent current user.
|
|
36
|
+
*/
|
|
37
|
+
currentUser(currentUserContext: ICurrentUserContext): this;
|
|
34
38
|
/**
|
|
35
39
|
* Use this to pass in userSubscriptionPackage.
|
|
36
40
|
*
|
|
@@ -43,12 +47,6 @@ export declare class MockContextProviderBuilder {
|
|
|
43
47
|
* @param developerSettingsContext - The developer settings context to use.
|
|
44
48
|
*/
|
|
45
49
|
supportedFeatures(features?: string[]): this;
|
|
46
|
-
/**
|
|
47
|
-
* Assume this user
|
|
48
|
-
*
|
|
49
|
-
* @param assumeUser - The user to assume.
|
|
50
|
-
*/
|
|
51
|
-
assumeUser(assumeUser: ICurrentUserContext["assumedUser"]): this;
|
|
52
50
|
/**
|
|
53
51
|
* Use this Router Props with the given mocks.
|
|
54
52
|
*
|