@trackunit/react-test-setup 1.8.52 → 1.8.55
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.cjs.js +16 -9
- package/index.esm.js +16 -9
- package/package.json +2 -5
- package/src/setupReactTestingLibrary.d.ts +0 -2
package/index.cjs.js
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var failOnConsole = require('jest-fail-on-console');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
require('@okta/okta-react');
|
|
6
5
|
require('@testing-library/jest-dom');
|
|
7
6
|
var react = require('@testing-library/react');
|
|
8
|
-
require('react-router-dom');
|
|
9
7
|
var polyfill = require('@js-temporal/polyfill');
|
|
10
8
|
var web = require('@react-spring/web');
|
|
11
9
|
var util = require('util');
|
|
@@ -401,10 +399,13 @@ const setupResponseForTanstackRouter = () => {
|
|
|
401
399
|
* setupReactTestingLibrary();
|
|
402
400
|
*/
|
|
403
401
|
const setupReactTestingLibrary = () => {
|
|
402
|
+
setupResponseForTanstackRouter();
|
|
403
|
+
// UserClaims
|
|
404
404
|
const mockedClaims = {
|
|
405
405
|
sub: "sub",
|
|
406
406
|
name: "user",
|
|
407
407
|
};
|
|
408
|
+
// IDToken
|
|
408
409
|
const mockedIdToken = {
|
|
409
410
|
idToken: "idToken",
|
|
410
411
|
claims: mockedClaims,
|
|
@@ -414,6 +415,7 @@ const setupReactTestingLibrary = () => {
|
|
|
414
415
|
issuer: "issuer",
|
|
415
416
|
clientId: "clientId",
|
|
416
417
|
};
|
|
418
|
+
// AccessToken
|
|
417
419
|
const mockedAccessToken = {
|
|
418
420
|
accessToken: "accessToken",
|
|
419
421
|
claims: mockedClaims,
|
|
@@ -423,12 +425,12 @@ const setupReactTestingLibrary = () => {
|
|
|
423
425
|
authorizeUrl: "authorize.url",
|
|
424
426
|
scopes: [],
|
|
425
427
|
};
|
|
428
|
+
// AuthState
|
|
426
429
|
const mockedAuthState = {
|
|
427
430
|
accessToken: mockedAccessToken,
|
|
428
431
|
idToken: mockedIdToken,
|
|
429
432
|
isAuthenticated: true,
|
|
430
433
|
};
|
|
431
|
-
setupResponseForTanstackRouter();
|
|
432
434
|
const mockedOktaAuth = () => {
|
|
433
435
|
return {
|
|
434
436
|
oktaAuth: {
|
|
@@ -464,12 +466,17 @@ const setupReactTestingLibrary = () => {
|
|
|
464
466
|
authState: mockedAuthState,
|
|
465
467
|
};
|
|
466
468
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
469
|
+
try {
|
|
470
|
+
// This ensures its being mocked in jest.
|
|
471
|
+
jest.mock("@okta/okta-react", () => {
|
|
472
|
+
return {
|
|
473
|
+
useOktaAuth: () => mockedOktaAuth(),
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
catch (_) {
|
|
478
|
+
// ignore if the mock cannot be created, in case the library is not installed
|
|
479
|
+
}
|
|
473
480
|
};
|
|
474
481
|
|
|
475
482
|
/**
|
package/index.esm.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import failOnConsole from 'jest-fail-on-console';
|
|
2
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import '@okta/okta-react';
|
|
4
3
|
import '@testing-library/jest-dom';
|
|
5
4
|
import { cleanup, act } from '@testing-library/react';
|
|
6
|
-
import 'react-router-dom';
|
|
7
5
|
import { Temporal } from '@js-temporal/polyfill';
|
|
8
6
|
import { Globals } from '@react-spring/web';
|
|
9
7
|
import { TextEncoder, TextDecoder } from 'util';
|
|
@@ -380,10 +378,13 @@ const setupResponseForTanstackRouter = () => {
|
|
|
380
378
|
* setupReactTestingLibrary();
|
|
381
379
|
*/
|
|
382
380
|
const setupReactTestingLibrary = () => {
|
|
381
|
+
setupResponseForTanstackRouter();
|
|
382
|
+
// UserClaims
|
|
383
383
|
const mockedClaims = {
|
|
384
384
|
sub: "sub",
|
|
385
385
|
name: "user",
|
|
386
386
|
};
|
|
387
|
+
// IDToken
|
|
387
388
|
const mockedIdToken = {
|
|
388
389
|
idToken: "idToken",
|
|
389
390
|
claims: mockedClaims,
|
|
@@ -393,6 +394,7 @@ const setupReactTestingLibrary = () => {
|
|
|
393
394
|
issuer: "issuer",
|
|
394
395
|
clientId: "clientId",
|
|
395
396
|
};
|
|
397
|
+
// AccessToken
|
|
396
398
|
const mockedAccessToken = {
|
|
397
399
|
accessToken: "accessToken",
|
|
398
400
|
claims: mockedClaims,
|
|
@@ -402,12 +404,12 @@ const setupReactTestingLibrary = () => {
|
|
|
402
404
|
authorizeUrl: "authorize.url",
|
|
403
405
|
scopes: [],
|
|
404
406
|
};
|
|
407
|
+
// AuthState
|
|
405
408
|
const mockedAuthState = {
|
|
406
409
|
accessToken: mockedAccessToken,
|
|
407
410
|
idToken: mockedIdToken,
|
|
408
411
|
isAuthenticated: true,
|
|
409
412
|
};
|
|
410
|
-
setupResponseForTanstackRouter();
|
|
411
413
|
const mockedOktaAuth = () => {
|
|
412
414
|
return {
|
|
413
415
|
oktaAuth: {
|
|
@@ -443,12 +445,17 @@ const setupReactTestingLibrary = () => {
|
|
|
443
445
|
authState: mockedAuthState,
|
|
444
446
|
};
|
|
445
447
|
};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
try {
|
|
449
|
+
// This ensures its being mocked in jest.
|
|
450
|
+
jest.mock("@okta/okta-react", () => {
|
|
451
|
+
return {
|
|
452
|
+
useOktaAuth: () => mockedOktaAuth(),
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
catch (_) {
|
|
457
|
+
// ignore if the mock cannot be created, in case the library is not installed
|
|
458
|
+
}
|
|
452
459
|
};
|
|
453
460
|
|
|
454
461
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-test-setup",
|
|
3
3
|
"description": "Test setup utilities for React applications",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.55",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
7
|
"engines": {
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@googlemaps/jest-mocks": "2.22.6",
|
|
24
|
-
"@okta/okta-auth-js": "^7.14.0",
|
|
25
24
|
"@react-spring/web": "9.7.5",
|
|
26
25
|
"@testing-library/jest-dom": "^6.9.1",
|
|
27
26
|
"@testing-library/react": "16.2.0",
|
|
@@ -32,10 +31,8 @@
|
|
|
32
31
|
"react-i18next": "^15.5.1",
|
|
33
32
|
"react-virtualized-auto-sizer": "^1.0.20",
|
|
34
33
|
"web-streams-polyfill": "^4.2.0",
|
|
35
|
-
"@okta/okta-react": "^6.10.0",
|
|
36
34
|
"jest": "30.0.5",
|
|
37
|
-
"@js-temporal/polyfill": "^0.5.1"
|
|
38
|
-
"react-router-dom": "6.30.3"
|
|
35
|
+
"@js-temporal/polyfill": "^0.5.1"
|
|
39
36
|
},
|
|
40
37
|
"module": "./index.esm.js",
|
|
41
38
|
"main": "./index.cjs.js",
|