@@ -585,21 +585,15 @@ describe('calls the NoIdentityAvailable event', () => {
585
585
uid2 . init ( {
586
586
identity : expiredIdentity ,
587
587
} ) ;
588
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
589
- identity : expiredIdentity ,
590
- } ) ;
588
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
591
589
} ) ;
592
590
test ( 'when init is already complete but the existing identity is expired' , ( ) => {
593
591
uid2 . init ( {
594
592
identity : expiredIdentity ,
595
593
} ) ;
596
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
597
- identity : null ,
598
- } ) ;
594
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
599
595
uid2 . init ( { } ) ;
600
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
601
- identity : expiredIdentity ,
602
- } ) ;
596
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
603
597
} ) ;
604
598
test ( 'when identity is expired but refreshable' , ( ) => {
605
599
let expiredRefreshableIdentity = makeIdentity ( {
@@ -609,52 +603,40 @@ describe('calls the NoIdentityAvailable event', () => {
609
603
uid2 . init ( { identity : expiredRefreshableIdentity } ) ;
610
604
611
605
// in this case, identity is temporarily unavailable but still unavailable
612
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
613
- identity : null ,
614
- } ) ;
606
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
615
607
} ) ;
616
608
test ( 'when login is required' , ( ) => {
617
609
uid2 . isLoginRequired ( ) ;
618
610
619
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
620
- identity : null ,
621
- } ) ;
611
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
622
612
} ) ;
623
613
test ( 'when get identity returns null or get advertising token returns undefined' , ( ) => {
624
614
const nullIdentity = uid2 . getIdentity ( ) ;
625
615
626
616
expect ( nullIdentity ) . toBeNull ( ) ;
627
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
628
- identity : null ,
629
- } ) ;
617
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
630
618
} ) ;
631
619
test ( 'when there is no advertising token' , ( ) => {
632
620
const token = uid2 . getAdvertisingToken ( ) ;
633
621
634
622
expect ( token ) . toBeUndefined ( ) ;
635
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
636
- identity : null ,
637
- } ) ;
623
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
638
624
} ) ;
639
625
test ( 'when cstg does not succeed' , ( ) => {
640
626
uid2 . init ( { } ) ;
641
627
expect ( uid2 . setIdentityFromEmail ( 'a' , mocks . makeUid2CstgOption ( ) ) ) . rejects . toThrow (
642
628
'Invalid email address'
643
629
) ;
644
630
645
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
646
- identity : null ,
647
- } ) ;
631
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
648
632
} ) ;
649
633
test ( 'when an identity was valid but has since expired' , ( ) => {
650
634
uid2 . init ( { } ) ;
651
635
expect ( uid2 . setIdentityFromEmail ( 'a' , mocks . makeUid2CstgOption ( ) ) ) . rejects . toThrow (
652
636
'Invalid email address'
653
637
) ;
654
638
655
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
656
- identity : null ,
657
- } ) ;
639
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
658
640
} ) ;
659
641
test ( 'when identity was valid on init but has since expired' , ( ) => {
660
642
const refreshFrom = Date . now ( ) + 100 ;
@@ -672,9 +654,7 @@ describe('calls the NoIdentityAvailable event', () => {
672
654
673
655
uid2 . isIdentityAvailable ( ) ;
674
656
675
- expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
676
- identity : originalIdentity ,
677
- } ) ;
657
+ expect ( handler ) . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
678
658
} ) ;
679
659
} ) ;
680
660
@@ -690,27 +670,19 @@ describe('does not call NoIdentityAvailable event', () => {
690
670
uid2 . init ( { } ) ;
691
671
handler = jest . fn ( ) ;
692
672
uid2 . setIdentity ( validIdentity ) ;
693
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
694
- identity : null ,
695
- } ) ;
673
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
696
674
697
675
uid2 . getIdentity ( ) ;
698
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
699
- identity : null ,
700
- } ) ;
676
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
701
677
702
678
uid2 . getAdvertisingToken ( ) ;
703
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
704
- identity : null ,
705
- } ) ;
679
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
706
680
} ) ;
707
681
test ( 'when identity is set with opted out identity' , ( ) => {
708
682
uid2 . init ( { } ) ;
709
683
let optedOutIdentity = makeIdentity ( { status : 'optout' } ) ;
710
684
uid2 . setIdentity ( optedOutIdentity ) ;
711
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
712
- identity : null ,
713
- } ) ;
685
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
714
686
} ) ;
715
687
test ( 'when cstg is successful' , async ( ) => {
716
688
uid2 . init ( { } ) ;
@@ -719,16 +691,12 @@ describe('does not call NoIdentityAvailable event', () => {
719
691
await uid2 . setIdentityFromEmail ( 'test@test.com' , mocks . makeUid2CstgOption ( ) ) ;
720
692
} ) . not . toThrow ( ) ;
721
693
722
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
723
- identity : null ,
724
- } ) ;
694
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
725
695
} ) ;
726
696
test ( 'when identity is set with local storage and init has never been' , ( ) => {
727
697
mocks . setUid2LocalStorage ( validIdentity ) ;
728
698
uid2 . isIdentityAvailable ( ) ;
729
699
730
- expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , {
731
- identity : null ,
732
- } ) ;
700
+ expect ( handler ) . not . toHaveBeenLastCalledWith ( EventType . NoIdentityAvailable , { identity : null } ) ;
733
701
} ) ;
734
702
} ) ;
0 commit comments