@trackunit/react-core-contexts-test 0.1.73 → 0.1.75
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 +156 -0
- package/index2.js +156 -0
- package/package.json +3 -3
- package/src/TrackunitProvidersMockBuilder.d.ts +155 -0
package/index2.cjs
CHANGED
|
@@ -160,6 +160,7 @@ const mockEnvironmentContext = {
|
|
|
160
160
|
managerClassicUrl: "https://sso.trackunit.com",
|
|
161
161
|
googleMapsApiKey: "",
|
|
162
162
|
amplitudeApiKey: "",
|
|
163
|
+
amplitudeApiEndpoint: "",
|
|
163
164
|
graphqlPublicUrl: "",
|
|
164
165
|
graphqlManagerUrl: "",
|
|
165
166
|
graphqlManagerImageUploadUrl: "",
|
|
@@ -345,6 +346,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
345
346
|
* Defaults to mockAnalyticsContext.
|
|
346
347
|
*
|
|
347
348
|
* @see mockAnalyticsContext
|
|
349
|
+
* @example
|
|
350
|
+
* ...
|
|
351
|
+
* it("should allow render", async () => {
|
|
352
|
+
* await trackunitProviders().analytics(yourPartialAnalyticsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
353
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
354
|
+
* });
|
|
355
|
+
* ...
|
|
356
|
+
* @example
|
|
357
|
+
* ...
|
|
358
|
+
* it("should allow renderHook", async () => {
|
|
359
|
+
* const { result } = await trackunitProviders().analytics(yourPartialAnalyticsMock).renderHook(() => useYourTestHook());
|
|
360
|
+
* expect(result.current).toEqual(anything());
|
|
361
|
+
* });
|
|
362
|
+
* ...
|
|
348
363
|
* @param analyticsContext - The analytics context to use.
|
|
349
364
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
350
365
|
*/
|
|
@@ -358,6 +373,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
358
373
|
* Defaults to mockEnvironmentContext.
|
|
359
374
|
*
|
|
360
375
|
* @see mockEnvironmentContext
|
|
376
|
+
* @example
|
|
377
|
+
* ...
|
|
378
|
+
* it("should allow render", async () => {
|
|
379
|
+
* await trackunitProviders().environment(yourPartialEnvironmentsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
380
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
381
|
+
* });
|
|
382
|
+
* ...
|
|
383
|
+
* @example
|
|
384
|
+
* ...
|
|
385
|
+
* it("should allow renderHook", async () => {
|
|
386
|
+
* const { result } = await trackunitProviders().environment(yourPartialEnvironmentMock).renderHook(() => useYourTestHook());
|
|
387
|
+
* expect(result.current).toEqual(anything());
|
|
388
|
+
* });
|
|
389
|
+
* ...
|
|
361
390
|
* @param environmentContext - The environment context to use.
|
|
362
391
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
363
392
|
*/
|
|
@@ -370,6 +399,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
370
399
|
* Defaults to mockCurrentUserContext.
|
|
371
400
|
*
|
|
372
401
|
* @see mockCurrentUserContext
|
|
402
|
+
* @example
|
|
403
|
+
* ...
|
|
404
|
+
* it("should allow render", async () => {
|
|
405
|
+
* await trackunitProviders().currentUser(yourPartialCurrentUserMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
406
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
407
|
+
* });
|
|
408
|
+
* ...
|
|
409
|
+
* @example
|
|
410
|
+
* ...
|
|
411
|
+
* it("should allow renderHook", async () => {
|
|
412
|
+
* const { result } = await trackunitProviders().currentUser(yourPartialCurrentUserMock).renderHook(() => useYourTestHook());
|
|
413
|
+
* expect(result.current).toEqual(anything());
|
|
414
|
+
* });
|
|
415
|
+
* ...
|
|
373
416
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
374
417
|
*/
|
|
375
418
|
currentUser(currentUserContext) {
|
|
@@ -381,6 +424,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
381
424
|
* Defaults to mockUserSubscriptionContext.
|
|
382
425
|
*
|
|
383
426
|
* @see mockUserSubscriptionContext
|
|
427
|
+
* @example
|
|
428
|
+
* ...
|
|
429
|
+
* it("should allow render", async () => {
|
|
430
|
+
* await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
431
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
432
|
+
* });
|
|
433
|
+
* ...
|
|
434
|
+
* @example
|
|
435
|
+
* ...
|
|
436
|
+
* it("should allow renderHook", async () => {
|
|
437
|
+
* const { result } = await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).renderHook(() => useYourTestHook());
|
|
438
|
+
* expect(result.current).toEqual(anything());
|
|
439
|
+
* });
|
|
440
|
+
* ...
|
|
384
441
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
385
442
|
*/
|
|
386
443
|
userSubscription(userSubscription) {
|
|
@@ -400,6 +457,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
400
457
|
* Defaults to mockAssetSortingContext.
|
|
401
458
|
*
|
|
402
459
|
* @see mockAssetSortingContext
|
|
460
|
+
* @example
|
|
461
|
+
* ...
|
|
462
|
+
* it("should allow render", async () => {
|
|
463
|
+
* await trackunitProviders().assetSorting(yourPartialAssetSortingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
464
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
465
|
+
* });
|
|
466
|
+
* ...
|
|
467
|
+
* @example
|
|
468
|
+
* ...
|
|
469
|
+
* it("should allow renderHook", async () => {
|
|
470
|
+
* const { result } = await trackunitProviders().assetSorting(yourPartialAssetSortingMock).renderHook(() => useYourTestHook());
|
|
471
|
+
* expect(result.current).toEqual(anything());
|
|
472
|
+
* });
|
|
473
|
+
* ...
|
|
403
474
|
* @param assetSortingContext - Override the default context.
|
|
404
475
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
405
476
|
*/
|
|
@@ -412,6 +483,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
412
483
|
* Defaults to mockOemBrandingContext.
|
|
413
484
|
*
|
|
414
485
|
* @see mockOemBrandingContext
|
|
486
|
+
* @example
|
|
487
|
+
* ...
|
|
488
|
+
* it("should allow render", async () => {
|
|
489
|
+
* await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
490
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
491
|
+
* });
|
|
492
|
+
* ...
|
|
493
|
+
* @example
|
|
494
|
+
* ...
|
|
495
|
+
* it("should allow renderHook", async () => {
|
|
496
|
+
* const { result } = await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).renderHook(() => useYourTestHook());
|
|
497
|
+
* expect(result.current).toEqual(anything());
|
|
498
|
+
* });
|
|
499
|
+
* ...
|
|
415
500
|
* @param oemBrandingContext - Override the default context.
|
|
416
501
|
*/
|
|
417
502
|
oemBrandingContext(oemBrandingContext) {
|
|
@@ -423,6 +508,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
423
508
|
* Defaults to mockToastContext.
|
|
424
509
|
*
|
|
425
510
|
* @see mockToastContext
|
|
511
|
+
* @example
|
|
512
|
+
* ...
|
|
513
|
+
* it("should allow render", async () => {
|
|
514
|
+
* await trackunitProviders().toast(yourPartialToastMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
515
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
516
|
+
* });
|
|
517
|
+
* ...
|
|
518
|
+
* @example
|
|
519
|
+
* ...
|
|
520
|
+
* it("should allow renderHook", async () => {
|
|
521
|
+
* const { result } = await trackunitProviders().toast(yourPartialToastMock).renderHook(() => useYourTestHook());
|
|
522
|
+
* expect(result.current).toEqual(anything());
|
|
523
|
+
* });
|
|
524
|
+
* ...
|
|
426
525
|
* @param toastContext - Override the default toast context.
|
|
427
526
|
*/
|
|
428
527
|
toast(toastContext) {
|
|
@@ -433,6 +532,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
433
532
|
* Use this global selection.
|
|
434
533
|
* Defaults to null.
|
|
435
534
|
*
|
|
535
|
+
* @example
|
|
536
|
+
* ...
|
|
537
|
+
* it("should allow render", async () => {
|
|
538
|
+
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
539
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
540
|
+
* });
|
|
541
|
+
* ...
|
|
542
|
+
* @example
|
|
543
|
+
* ...
|
|
544
|
+
* it("should allow renderHook", async () => {
|
|
545
|
+
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
546
|
+
* expect(result.current).toEqual(anything());
|
|
547
|
+
* });
|
|
548
|
+
* ...
|
|
436
549
|
* @param globalSelection - The global selection to use.
|
|
437
550
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
438
551
|
*/
|
|
@@ -443,6 +556,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
443
556
|
/**
|
|
444
557
|
* Use this token.
|
|
445
558
|
*
|
|
559
|
+
* @example
|
|
560
|
+
* ...
|
|
561
|
+
* it("should allow render", async () => {
|
|
562
|
+
* await trackunitProviders().token(yourMockedToken).render(<YourTestComponent data-testid="yourTestId" />);
|
|
563
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
564
|
+
* });
|
|
565
|
+
* ...
|
|
566
|
+
* @example
|
|
567
|
+
* ...
|
|
568
|
+
* it("should allow renderHook", async () => {
|
|
569
|
+
* const { result } = await trackunitProviders().token(yourMockedToken).renderHook(() => useYourTestHook());
|
|
570
|
+
* expect(result.current).toEqual(anything());
|
|
571
|
+
* });
|
|
572
|
+
* ...
|
|
446
573
|
* @param token - The token to use.
|
|
447
574
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
448
575
|
*/
|
|
@@ -453,6 +580,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
453
580
|
/**
|
|
454
581
|
* Use this Router Props with the given mocks.
|
|
455
582
|
*
|
|
583
|
+
* @example
|
|
584
|
+
* ...
|
|
585
|
+
* it("should allow render", async () => {
|
|
586
|
+
* await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
587
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
588
|
+
* });
|
|
589
|
+
* ...
|
|
590
|
+
* @example
|
|
591
|
+
* ...
|
|
592
|
+
* it("should allow renderHook", async () => {
|
|
593
|
+
* const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
|
|
594
|
+
* expect(result.current).toEqual(anything());
|
|
595
|
+
* });
|
|
596
|
+
* ...
|
|
456
597
|
* @param routerProps - The router props to use.
|
|
457
598
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
458
599
|
*/
|
|
@@ -463,6 +604,21 @@ class TrackunitProvidersMockBuilder {
|
|
|
463
604
|
/**
|
|
464
605
|
* Use this Manager Apollo Context Provider with the given mocks.
|
|
465
606
|
*
|
|
607
|
+
* @see https://www.apollographql.com/docs/react/development-testing/testing
|
|
608
|
+
* @example
|
|
609
|
+
* ...
|
|
610
|
+
* it("should allow render", async () => {
|
|
611
|
+
* await trackunitProviders().apollo([yourApolloMocks]).render(<YourTestComponent data-testid="yourTestId" />);
|
|
612
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
613
|
+
* });
|
|
614
|
+
* ...
|
|
615
|
+
* @example
|
|
616
|
+
* ...
|
|
617
|
+
* it("should allow renderHook", async () => {
|
|
618
|
+
* const { result } = await trackunitProviders().apollo([yourApolloMocks]).renderHook(() => useYourTestHook());
|
|
619
|
+
* expect(result.current).toEqual(anything());
|
|
620
|
+
* });
|
|
621
|
+
* ...
|
|
466
622
|
* @param apolloMocks - The mocks to use for the ApolloProvider.
|
|
467
623
|
*/
|
|
468
624
|
apollo(apolloMocks) {
|
package/index2.js
CHANGED
|
@@ -154,6 +154,7 @@ const mockEnvironmentContext = {
|
|
|
154
154
|
managerClassicUrl: "https://sso.trackunit.com",
|
|
155
155
|
googleMapsApiKey: "",
|
|
156
156
|
amplitudeApiKey: "",
|
|
157
|
+
amplitudeApiEndpoint: "",
|
|
157
158
|
graphqlPublicUrl: "",
|
|
158
159
|
graphqlManagerUrl: "",
|
|
159
160
|
graphqlManagerImageUploadUrl: "",
|
|
@@ -339,6 +340,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
339
340
|
* Defaults to mockAnalyticsContext.
|
|
340
341
|
*
|
|
341
342
|
* @see mockAnalyticsContext
|
|
343
|
+
* @example
|
|
344
|
+
* ...
|
|
345
|
+
* it("should allow render", async () => {
|
|
346
|
+
* await trackunitProviders().analytics(yourPartialAnalyticsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
347
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
348
|
+
* });
|
|
349
|
+
* ...
|
|
350
|
+
* @example
|
|
351
|
+
* ...
|
|
352
|
+
* it("should allow renderHook", async () => {
|
|
353
|
+
* const { result } = await trackunitProviders().analytics(yourPartialAnalyticsMock).renderHook(() => useYourTestHook());
|
|
354
|
+
* expect(result.current).toEqual(anything());
|
|
355
|
+
* });
|
|
356
|
+
* ...
|
|
342
357
|
* @param analyticsContext - The analytics context to use.
|
|
343
358
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
344
359
|
*/
|
|
@@ -352,6 +367,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
352
367
|
* Defaults to mockEnvironmentContext.
|
|
353
368
|
*
|
|
354
369
|
* @see mockEnvironmentContext
|
|
370
|
+
* @example
|
|
371
|
+
* ...
|
|
372
|
+
* it("should allow render", async () => {
|
|
373
|
+
* await trackunitProviders().environment(yourPartialEnvironmentsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
374
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
375
|
+
* });
|
|
376
|
+
* ...
|
|
377
|
+
* @example
|
|
378
|
+
* ...
|
|
379
|
+
* it("should allow renderHook", async () => {
|
|
380
|
+
* const { result } = await trackunitProviders().environment(yourPartialEnvironmentMock).renderHook(() => useYourTestHook());
|
|
381
|
+
* expect(result.current).toEqual(anything());
|
|
382
|
+
* });
|
|
383
|
+
* ...
|
|
355
384
|
* @param environmentContext - The environment context to use.
|
|
356
385
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
357
386
|
*/
|
|
@@ -364,6 +393,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
364
393
|
* Defaults to mockCurrentUserContext.
|
|
365
394
|
*
|
|
366
395
|
* @see mockCurrentUserContext
|
|
396
|
+
* @example
|
|
397
|
+
* ...
|
|
398
|
+
* it("should allow render", async () => {
|
|
399
|
+
* await trackunitProviders().currentUser(yourPartialCurrentUserMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
400
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
401
|
+
* });
|
|
402
|
+
* ...
|
|
403
|
+
* @example
|
|
404
|
+
* ...
|
|
405
|
+
* it("should allow renderHook", async () => {
|
|
406
|
+
* const { result } = await trackunitProviders().currentUser(yourPartialCurrentUserMock).renderHook(() => useYourTestHook());
|
|
407
|
+
* expect(result.current).toEqual(anything());
|
|
408
|
+
* });
|
|
409
|
+
* ...
|
|
367
410
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
368
411
|
*/
|
|
369
412
|
currentUser(currentUserContext) {
|
|
@@ -375,6 +418,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
375
418
|
* Defaults to mockUserSubscriptionContext.
|
|
376
419
|
*
|
|
377
420
|
* @see mockUserSubscriptionContext
|
|
421
|
+
* @example
|
|
422
|
+
* ...
|
|
423
|
+
* it("should allow render", async () => {
|
|
424
|
+
* await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
425
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
426
|
+
* });
|
|
427
|
+
* ...
|
|
428
|
+
* @example
|
|
429
|
+
* ...
|
|
430
|
+
* it("should allow renderHook", async () => {
|
|
431
|
+
* const { result } = await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).renderHook(() => useYourTestHook());
|
|
432
|
+
* expect(result.current).toEqual(anything());
|
|
433
|
+
* });
|
|
434
|
+
* ...
|
|
378
435
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
379
436
|
*/
|
|
380
437
|
userSubscription(userSubscription) {
|
|
@@ -394,6 +451,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
394
451
|
* Defaults to mockAssetSortingContext.
|
|
395
452
|
*
|
|
396
453
|
* @see mockAssetSortingContext
|
|
454
|
+
* @example
|
|
455
|
+
* ...
|
|
456
|
+
* it("should allow render", async () => {
|
|
457
|
+
* await trackunitProviders().assetSorting(yourPartialAssetSortingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
458
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
459
|
+
* });
|
|
460
|
+
* ...
|
|
461
|
+
* @example
|
|
462
|
+
* ...
|
|
463
|
+
* it("should allow renderHook", async () => {
|
|
464
|
+
* const { result } = await trackunitProviders().assetSorting(yourPartialAssetSortingMock).renderHook(() => useYourTestHook());
|
|
465
|
+
* expect(result.current).toEqual(anything());
|
|
466
|
+
* });
|
|
467
|
+
* ...
|
|
397
468
|
* @param assetSortingContext - Override the default context.
|
|
398
469
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
399
470
|
*/
|
|
@@ -406,6 +477,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
406
477
|
* Defaults to mockOemBrandingContext.
|
|
407
478
|
*
|
|
408
479
|
* @see mockOemBrandingContext
|
|
480
|
+
* @example
|
|
481
|
+
* ...
|
|
482
|
+
* it("should allow render", async () => {
|
|
483
|
+
* await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
484
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
485
|
+
* });
|
|
486
|
+
* ...
|
|
487
|
+
* @example
|
|
488
|
+
* ...
|
|
489
|
+
* it("should allow renderHook", async () => {
|
|
490
|
+
* const { result } = await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).renderHook(() => useYourTestHook());
|
|
491
|
+
* expect(result.current).toEqual(anything());
|
|
492
|
+
* });
|
|
493
|
+
* ...
|
|
409
494
|
* @param oemBrandingContext - Override the default context.
|
|
410
495
|
*/
|
|
411
496
|
oemBrandingContext(oemBrandingContext) {
|
|
@@ -417,6 +502,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
417
502
|
* Defaults to mockToastContext.
|
|
418
503
|
*
|
|
419
504
|
* @see mockToastContext
|
|
505
|
+
* @example
|
|
506
|
+
* ...
|
|
507
|
+
* it("should allow render", async () => {
|
|
508
|
+
* await trackunitProviders().toast(yourPartialToastMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
509
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
510
|
+
* });
|
|
511
|
+
* ...
|
|
512
|
+
* @example
|
|
513
|
+
* ...
|
|
514
|
+
* it("should allow renderHook", async () => {
|
|
515
|
+
* const { result } = await trackunitProviders().toast(yourPartialToastMock).renderHook(() => useYourTestHook());
|
|
516
|
+
* expect(result.current).toEqual(anything());
|
|
517
|
+
* });
|
|
518
|
+
* ...
|
|
420
519
|
* @param toastContext - Override the default toast context.
|
|
421
520
|
*/
|
|
422
521
|
toast(toastContext) {
|
|
@@ -427,6 +526,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
427
526
|
* Use this global selection.
|
|
428
527
|
* Defaults to null.
|
|
429
528
|
*
|
|
529
|
+
* @example
|
|
530
|
+
* ...
|
|
531
|
+
* it("should allow render", async () => {
|
|
532
|
+
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
533
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
534
|
+
* });
|
|
535
|
+
* ...
|
|
536
|
+
* @example
|
|
537
|
+
* ...
|
|
538
|
+
* it("should allow renderHook", async () => {
|
|
539
|
+
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
540
|
+
* expect(result.current).toEqual(anything());
|
|
541
|
+
* });
|
|
542
|
+
* ...
|
|
430
543
|
* @param globalSelection - The global selection to use.
|
|
431
544
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
432
545
|
*/
|
|
@@ -437,6 +550,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
437
550
|
/**
|
|
438
551
|
* Use this token.
|
|
439
552
|
*
|
|
553
|
+
* @example
|
|
554
|
+
* ...
|
|
555
|
+
* it("should allow render", async () => {
|
|
556
|
+
* await trackunitProviders().token(yourMockedToken).render(<YourTestComponent data-testid="yourTestId" />);
|
|
557
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
558
|
+
* });
|
|
559
|
+
* ...
|
|
560
|
+
* @example
|
|
561
|
+
* ...
|
|
562
|
+
* it("should allow renderHook", async () => {
|
|
563
|
+
* const { result } = await trackunitProviders().token(yourMockedToken).renderHook(() => useYourTestHook());
|
|
564
|
+
* expect(result.current).toEqual(anything());
|
|
565
|
+
* });
|
|
566
|
+
* ...
|
|
440
567
|
* @param token - The token to use.
|
|
441
568
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
442
569
|
*/
|
|
@@ -447,6 +574,20 @@ class TrackunitProvidersMockBuilder {
|
|
|
447
574
|
/**
|
|
448
575
|
* Use this Router Props with the given mocks.
|
|
449
576
|
*
|
|
577
|
+
* @example
|
|
578
|
+
* ...
|
|
579
|
+
* it("should allow render", async () => {
|
|
580
|
+
* await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
581
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
582
|
+
* });
|
|
583
|
+
* ...
|
|
584
|
+
* @example
|
|
585
|
+
* ...
|
|
586
|
+
* it("should allow renderHook", async () => {
|
|
587
|
+
* const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
|
|
588
|
+
* expect(result.current).toEqual(anything());
|
|
589
|
+
* });
|
|
590
|
+
* ...
|
|
450
591
|
* @param routerProps - The router props to use.
|
|
451
592
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
452
593
|
*/
|
|
@@ -457,6 +598,21 @@ class TrackunitProvidersMockBuilder {
|
|
|
457
598
|
/**
|
|
458
599
|
* Use this Manager Apollo Context Provider with the given mocks.
|
|
459
600
|
*
|
|
601
|
+
* @see https://www.apollographql.com/docs/react/development-testing/testing
|
|
602
|
+
* @example
|
|
603
|
+
* ...
|
|
604
|
+
* it("should allow render", async () => {
|
|
605
|
+
* await trackunitProviders().apollo([yourApolloMocks]).render(<YourTestComponent data-testid="yourTestId" />);
|
|
606
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
607
|
+
* });
|
|
608
|
+
* ...
|
|
609
|
+
* @example
|
|
610
|
+
* ...
|
|
611
|
+
* it("should allow renderHook", async () => {
|
|
612
|
+
* const { result } = await trackunitProviders().apollo([yourApolloMocks]).renderHook(() => useYourTestHook());
|
|
613
|
+
* expect(result.current).toEqual(anything());
|
|
614
|
+
* });
|
|
615
|
+
* ...
|
|
460
616
|
* @param apolloMocks - The mocks to use for the ApolloProvider.
|
|
461
617
|
*/
|
|
462
618
|
apollo(apolloMocks) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.75",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"types": "./src/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@apollo/client": "3.7.10",
|
|
15
|
-
"@trackunit/react-core-contexts-api": "0.2.
|
|
16
|
-
"@trackunit/react-core-hooks": "0.2.
|
|
15
|
+
"@trackunit/react-core-contexts-api": "0.2.40",
|
|
16
|
+
"@trackunit/react-core-hooks": "0.2.64",
|
|
17
17
|
"@trackunit/tailwind-styled-components": "0.0.57",
|
|
18
18
|
"graphql": "15.8.0",
|
|
19
19
|
"lodash": "4.17.21",
|
|
@@ -29,6 +29,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
29
29
|
* Defaults to mockAnalyticsContext.
|
|
30
30
|
*
|
|
31
31
|
* @see mockAnalyticsContext
|
|
32
|
+
* @example
|
|
33
|
+
* ...
|
|
34
|
+
* it("should allow render", async () => {
|
|
35
|
+
* await trackunitProviders().analytics(yourPartialAnalyticsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
36
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
37
|
+
* });
|
|
38
|
+
* ...
|
|
39
|
+
* @example
|
|
40
|
+
* ...
|
|
41
|
+
* it("should allow renderHook", async () => {
|
|
42
|
+
* const { result } = await trackunitProviders().analytics(yourPartialAnalyticsMock).renderHook(() => useYourTestHook());
|
|
43
|
+
* expect(result.current).toEqual(anything());
|
|
44
|
+
* });
|
|
45
|
+
* ...
|
|
32
46
|
* @param analyticsContext - The analytics context to use.
|
|
33
47
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
34
48
|
*/
|
|
@@ -38,6 +52,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
38
52
|
* Defaults to mockEnvironmentContext.
|
|
39
53
|
*
|
|
40
54
|
* @see mockEnvironmentContext
|
|
55
|
+
* @example
|
|
56
|
+
* ...
|
|
57
|
+
* it("should allow render", async () => {
|
|
58
|
+
* await trackunitProviders().environment(yourPartialEnvironmentsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
59
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
60
|
+
* });
|
|
61
|
+
* ...
|
|
62
|
+
* @example
|
|
63
|
+
* ...
|
|
64
|
+
* it("should allow renderHook", async () => {
|
|
65
|
+
* const { result } = await trackunitProviders().environment(yourPartialEnvironmentMock).renderHook(() => useYourTestHook());
|
|
66
|
+
* expect(result.current).toEqual(anything());
|
|
67
|
+
* });
|
|
68
|
+
* ...
|
|
41
69
|
* @param environmentContext - The environment context to use.
|
|
42
70
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
43
71
|
*/
|
|
@@ -47,6 +75,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
47
75
|
* Defaults to mockCurrentUserContext.
|
|
48
76
|
*
|
|
49
77
|
* @see mockCurrentUserContext
|
|
78
|
+
* @example
|
|
79
|
+
* ...
|
|
80
|
+
* it("should allow render", async () => {
|
|
81
|
+
* await trackunitProviders().currentUser(yourPartialCurrentUserMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
82
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
83
|
+
* });
|
|
84
|
+
* ...
|
|
85
|
+
* @example
|
|
86
|
+
* ...
|
|
87
|
+
* it("should allow renderHook", async () => {
|
|
88
|
+
* const { result } = await trackunitProviders().currentUser(yourPartialCurrentUserMock).renderHook(() => useYourTestHook());
|
|
89
|
+
* expect(result.current).toEqual(anything());
|
|
90
|
+
* });
|
|
91
|
+
* ...
|
|
50
92
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
51
93
|
*/
|
|
52
94
|
currentUser(currentUserContext: Partial<ICurrentUserContext>): this;
|
|
@@ -55,6 +97,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
55
97
|
* Defaults to mockUserSubscriptionContext.
|
|
56
98
|
*
|
|
57
99
|
* @see mockUserSubscriptionContext
|
|
100
|
+
* @example
|
|
101
|
+
* ...
|
|
102
|
+
* it("should allow render", async () => {
|
|
103
|
+
* await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
104
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
105
|
+
* });
|
|
106
|
+
* ...
|
|
107
|
+
* @example
|
|
108
|
+
* ...
|
|
109
|
+
* it("should allow renderHook", async () => {
|
|
110
|
+
* const { result } = await trackunitProviders().userSubscription(yourPartialUserSubscriptionMock).renderHook(() => useYourTestHook());
|
|
111
|
+
* expect(result.current).toEqual(anything());
|
|
112
|
+
* });
|
|
113
|
+
* ...
|
|
58
114
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
59
115
|
*/
|
|
60
116
|
userSubscription(userSubscription: Partial<IUserSubscriptionContext> | {
|
|
@@ -65,6 +121,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
65
121
|
* Defaults to mockAssetSortingContext.
|
|
66
122
|
*
|
|
67
123
|
* @see mockAssetSortingContext
|
|
124
|
+
* @example
|
|
125
|
+
* ...
|
|
126
|
+
* it("should allow render", async () => {
|
|
127
|
+
* await trackunitProviders().assetSorting(yourPartialAssetSortingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
128
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
129
|
+
* });
|
|
130
|
+
* ...
|
|
131
|
+
* @example
|
|
132
|
+
* ...
|
|
133
|
+
* it("should allow renderHook", async () => {
|
|
134
|
+
* const { result } = await trackunitProviders().assetSorting(yourPartialAssetSortingMock).renderHook(() => useYourTestHook());
|
|
135
|
+
* expect(result.current).toEqual(anything());
|
|
136
|
+
* });
|
|
137
|
+
* ...
|
|
68
138
|
* @param assetSortingContext - Override the default context.
|
|
69
139
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
70
140
|
*/
|
|
@@ -74,6 +144,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
74
144
|
* Defaults to mockOemBrandingContext.
|
|
75
145
|
*
|
|
76
146
|
* @see mockOemBrandingContext
|
|
147
|
+
* @example
|
|
148
|
+
* ...
|
|
149
|
+
* it("should allow render", async () => {
|
|
150
|
+
* await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
151
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
152
|
+
* });
|
|
153
|
+
* ...
|
|
154
|
+
* @example
|
|
155
|
+
* ...
|
|
156
|
+
* it("should allow renderHook", async () => {
|
|
157
|
+
* const { result } = await trackunitProviders().oemBrandingContext(yourPartialOemBrandingMock).renderHook(() => useYourTestHook());
|
|
158
|
+
* expect(result.current).toEqual(anything());
|
|
159
|
+
* });
|
|
160
|
+
* ...
|
|
77
161
|
* @param oemBrandingContext - Override the default context.
|
|
78
162
|
*/
|
|
79
163
|
oemBrandingContext(oemBrandingContext: Partial<IOemBrandingContext>): this;
|
|
@@ -82,6 +166,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
82
166
|
* Defaults to mockToastContext.
|
|
83
167
|
*
|
|
84
168
|
* @see mockToastContext
|
|
169
|
+
* @example
|
|
170
|
+
* ...
|
|
171
|
+
* it("should allow render", async () => {
|
|
172
|
+
* await trackunitProviders().toast(yourPartialToastMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
173
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
174
|
+
* });
|
|
175
|
+
* ...
|
|
176
|
+
* @example
|
|
177
|
+
* ...
|
|
178
|
+
* it("should allow renderHook", async () => {
|
|
179
|
+
* const { result } = await trackunitProviders().toast(yourPartialToastMock).renderHook(() => useYourTestHook());
|
|
180
|
+
* expect(result.current).toEqual(anything());
|
|
181
|
+
* });
|
|
182
|
+
* ...
|
|
85
183
|
* @param toastContext - Override the default toast context.
|
|
86
184
|
*/
|
|
87
185
|
toast(toastContext: Partial<IToastContext>): this;
|
|
@@ -89,6 +187,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
89
187
|
* Use this global selection.
|
|
90
188
|
* Defaults to null.
|
|
91
189
|
*
|
|
190
|
+
* @example
|
|
191
|
+
* ...
|
|
192
|
+
* it("should allow render", async () => {
|
|
193
|
+
* await trackunitProviders().globalSelection(yourGlobalSelectionMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
194
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
195
|
+
* });
|
|
196
|
+
* ...
|
|
197
|
+
* @example
|
|
198
|
+
* ...
|
|
199
|
+
* it("should allow renderHook", async () => {
|
|
200
|
+
* const { result } = await trackunitProviders().globalSelection(yourGlobalSelectionMock).renderHook(() => useYourTestHook());
|
|
201
|
+
* expect(result.current).toEqual(anything());
|
|
202
|
+
* });
|
|
203
|
+
* ...
|
|
92
204
|
* @param globalSelection - The global selection to use.
|
|
93
205
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
94
206
|
*/
|
|
@@ -96,6 +208,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
96
208
|
/**
|
|
97
209
|
* Use this token.
|
|
98
210
|
*
|
|
211
|
+
* @example
|
|
212
|
+
* ...
|
|
213
|
+
* it("should allow render", async () => {
|
|
214
|
+
* await trackunitProviders().token(yourMockedToken).render(<YourTestComponent data-testid="yourTestId" />);
|
|
215
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
216
|
+
* });
|
|
217
|
+
* ...
|
|
218
|
+
* @example
|
|
219
|
+
* ...
|
|
220
|
+
* it("should allow renderHook", async () => {
|
|
221
|
+
* const { result } = await trackunitProviders().token(yourMockedToken).renderHook(() => useYourTestHook());
|
|
222
|
+
* expect(result.current).toEqual(anything());
|
|
223
|
+
* });
|
|
224
|
+
* ...
|
|
99
225
|
* @param token - The token to use.
|
|
100
226
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
101
227
|
*/
|
|
@@ -103,6 +229,20 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
103
229
|
/**
|
|
104
230
|
* Use this Router Props with the given mocks.
|
|
105
231
|
*
|
|
232
|
+
* @example
|
|
233
|
+
* ...
|
|
234
|
+
* it("should allow render", async () => {
|
|
235
|
+
* await trackunitProviders().routerProps(yourRouterPropsMock).render(<YourTestComponent data-testid="yourTestId" />);
|
|
236
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
237
|
+
* });
|
|
238
|
+
* ...
|
|
239
|
+
* @example
|
|
240
|
+
* ...
|
|
241
|
+
* it("should allow renderHook", async () => {
|
|
242
|
+
* const { result } = await trackunitProviders().routerProps(yourRouterPropsMock).renderHook(() => useYourTestHook());
|
|
243
|
+
* expect(result.current).toEqual(anything());
|
|
244
|
+
* });
|
|
245
|
+
* ...
|
|
106
246
|
* @param routerProps - The router props to use.
|
|
107
247
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
108
248
|
*/
|
|
@@ -110,6 +250,21 @@ export declare class TrackunitProvidersMockBuilder {
|
|
|
110
250
|
/**
|
|
111
251
|
* Use this Manager Apollo Context Provider with the given mocks.
|
|
112
252
|
*
|
|
253
|
+
* @see https://www.apollographql.com/docs/react/development-testing/testing
|
|
254
|
+
* @example
|
|
255
|
+
* ...
|
|
256
|
+
* it("should allow render", async () => {
|
|
257
|
+
* await trackunitProviders().apollo([yourApolloMocks]).render(<YourTestComponent data-testid="yourTestId" />);
|
|
258
|
+
* expect(screen.getByTestId("yourTestId")).toBeInTheDocument();
|
|
259
|
+
* });
|
|
260
|
+
* ...
|
|
261
|
+
* @example
|
|
262
|
+
* ...
|
|
263
|
+
* it("should allow renderHook", async () => {
|
|
264
|
+
* const { result } = await trackunitProviders().apollo([yourApolloMocks]).renderHook(() => useYourTestHook());
|
|
265
|
+
* expect(result.current).toEqual(anything());
|
|
266
|
+
* });
|
|
267
|
+
* ...
|
|
113
268
|
* @param apolloMocks - The mocks to use for the ApolloProvider.
|
|
114
269
|
*/
|
|
115
270
|
apollo(apolloMocks?: MockedResponse[]): this;
|