@@ -657,16 +657,25 @@ describe('NftController', () => {
657
657
658
658
const callActionSpy = jest
659
659
. spyOn ( messenger , 'call' )
660
+ // 1. `AccountsController:getAccount`
660
661
. mockReturnValueOnce ( OWNER_ACCOUNT )
661
- . mockResolvedValue ( { } ) ;
662
+ // 2. `AssetsContractController:getERC721OwnerOf`
663
+ . mockResolvedValueOnce ( OWNER_ADDRESS )
664
+ // 3. `AssetsContractController:getERC721TokenURI`
665
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
666
+ // 4. `ApprovalController:addRequest`
667
+ . mockResolvedValueOnce ( { } )
668
+ // 5. `AccountsController:getAccount`
669
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
670
+ // 6. `AssetsContractController:getERC721AssetName`
671
+ . mockResolvedValueOnce ( 'testERC721Name' )
672
+ // 7. `AssetsContractController:getERC721AssetSymbol`
673
+ . mockResolvedValueOnce ( 'testERC721Symbol' ) ;
662
674
663
675
await nftController . watchNft ( ERC721_NFT , ERC721 , 'https://test-dapp.com' ) ;
664
- // First call is `AccountsController:getAccount`
665
- // Fifth call is `ApprovalController:addRequest`
666
- // Sixth call is `AccountsController:getAccount`
667
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
676
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 7 ) ;
668
677
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
669
- 5 ,
678
+ 4 ,
670
679
'ApprovalController:addRequest' ,
671
680
{
672
681
id : requestId ,
@@ -727,16 +736,25 @@ describe('NftController', () => {
727
736
728
737
const callActionSpy = jest
729
738
. spyOn ( messenger , 'call' )
739
+ // 1. `AccountsController:getAccount`
740
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
741
+ // 2. `AssetsContractController:getERC721OwnerOf`
742
+ . mockResolvedValueOnce ( OWNER_ADDRESS )
743
+ // 3. `AssetsContractController:getERC721TokenURI`
744
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
745
+ // 4. `ApprovalController:addRequest`
746
+ . mockResolvedValueOnce ( { } )
747
+ // 5. `AccountsController:getAccount`
730
748
. mockReturnValueOnce ( OWNER_ACCOUNT )
731
- . mockResolvedValue ( { } ) ;
749
+ // 6. `AssetsContractController:getERC721AssetName`
750
+ . mockResolvedValueOnce ( 'testERC721Name' )
751
+ // 7. `AssetsContractController:getERC721AssetSymbol`
752
+ . mockResolvedValueOnce ( 'testERC721Symbol' ) ;
732
753
733
754
await nftController . watchNft ( ERC721_NFT , ERC721 , 'https://test-dapp.com' ) ;
734
- // First call is `AccountsController:getAccount`
735
- // Fifth call is `ApprovalController:addRequest`
736
- // Sixth call is `AccountsController:getAccount`
737
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
755
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 7 ) ;
738
756
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
739
- 5 ,
757
+ 4 ,
740
758
'ApprovalController:addRequest' ,
741
759
{
742
760
id : requestId ,
@@ -797,16 +815,25 @@ describe('NftController', () => {
797
815
798
816
const callActionSpy = jest
799
817
. spyOn ( messenger , 'call' )
818
+ // 1. `AccountsController:getAccount`
800
819
. mockReturnValueOnce ( OWNER_ACCOUNT )
801
- . mockResolvedValue ( { } ) ;
820
+ // 2. `AssetsContractController:getERC721OwnerOf`
821
+ . mockResolvedValueOnce ( OWNER_ADDRESS )
822
+ // 3. `AssetsContractController:getERC721TokenURI`
823
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
824
+ // 4. `ApprovalController:addRequest`
825
+ . mockResolvedValueOnce ( { } )
826
+ // 5. `AccountsController:getAccount`
827
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
828
+ // 6. `AssetsContractController:getERC721AssetName`
829
+ . mockResolvedValueOnce ( 'testERC721Name' )
830
+ // 7. `AssetsContractController:getERC721AssetSymbol`
831
+ . mockResolvedValueOnce ( 'testERC721Symbol' ) ;
802
832
803
833
await nftController . watchNft ( ERC721_NFT , ERC721 , 'https://test-dapp.com' ) ;
804
- // First call is `AccountsController:getAccount`
805
- // Fifth call is `ApprovalController:addRequest`
806
- // Sixth call is `AccountsController:getAccount`
807
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
834
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 7 ) ;
808
835
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
809
- 5 ,
836
+ 4 ,
810
837
'ApprovalController:addRequest' ,
811
838
{
812
839
id : requestId ,
@@ -868,16 +895,25 @@ describe('NftController', () => {
868
895
869
896
const callActionSpy = jest
870
897
. spyOn ( messenger , 'call' )
898
+ // 1. `AccountsController:getAccount`
899
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
900
+ // 2. `AssetsContractController:getERC721OwnerOf`
901
+ . mockResolvedValueOnce ( OWNER_ADDRESS )
902
+ // 3. `AssetsContractController:getERC721TokenURI`
903
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
904
+ // 4. `ApprovalController:addRequest`
905
+ . mockResolvedValueOnce ( { } )
906
+ // 5. `AccountsController:getAccount`
871
907
. mockReturnValueOnce ( OWNER_ACCOUNT )
872
- . mockResolvedValue ( { } ) ;
908
+ // 6. `AssetsContractController:getERC721AssetName`
909
+ . mockResolvedValueOnce ( 'testERC721Name' )
910
+ // 7. `AssetsContractController:getERC721AssetSymbol`
911
+ . mockResolvedValueOnce ( 'testERC721Symbol' ) ;
873
912
874
913
await nftController . watchNft ( ERC721_NFT , ERC721 , 'https://test-dapp.com' ) ;
875
- // First call is `AccountsController:getAccount`
876
- // Fifth call is `ApprovalController:addRequest`
877
- // Sixth call is `AccountsController:getAccount`
878
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
914
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 7 ) ;
879
915
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
880
- 5 ,
916
+ 4 ,
881
917
'ApprovalController:addRequest' ,
882
918
{
883
919
id : requestId ,
@@ -888,9 +924,9 @@ describe('NftController', () => {
888
924
interactingAddress : OWNER_ADDRESS ,
889
925
asset : {
890
926
...ERC721_NFT ,
891
- description : null ,
892
- image : null ,
893
- name : null ,
927
+ description : 'testERC721Description' ,
928
+ image : 'testERC721Image' ,
929
+ name : 'testERC721Name' ,
894
930
standard : ERC721 ,
895
931
} ,
896
932
} ,
@@ -942,20 +978,33 @@ describe('NftController', () => {
942
978
943
979
const callActionSpy = jest
944
980
. spyOn ( messenger , 'call' )
981
+ // 1. `AccountsController:getAccount`
945
982
. mockReturnValueOnce ( OWNER_ACCOUNT )
946
- . mockResolvedValue ( { } ) ;
983
+ // 2. `AssetsContractController:getERC721OwnerOf`
984
+ . mockRejectedValueOnce ( new Error ( 'Not an ERC721 contract' ) )
985
+ // 3. `AssetsContractController:getERC1155BalanceOf`
986
+ . mockResolvedValueOnce ( new BN ( 1 ) )
987
+ // 4. `AssetsContractController:getERC721TokenURI`
988
+ . mockRejectedValueOnce ( new Error ( 'Not an ERC721 contract' ) )
989
+ // 5. `AssetsContractController:getERC1155TokenURI`
990
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
991
+ // 6. `ApprovalController:addRequest`
992
+ . mockResolvedValueOnce ( { } )
993
+ // 7. `AccountsController:getAccount`
994
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
995
+ // 8. `AssetsContractController:getERC1155AssetName`
996
+ . mockResolvedValueOnce ( 'testERC1155Name' )
997
+ // 9. `AssetsContractController:getERC1155AssetSymbol`
998
+ . mockResolvedValueOnce ( 'testERC1155Symbol' ) ;
947
999
948
1000
await nftController . watchNft (
949
1001
ERC1155_NFT ,
950
1002
ERC1155 ,
951
1003
'https://etherscan.io' ,
952
1004
) ;
953
- // First call is `AccountsController:getAccount`
954
- // Fifth call is `ApprovalController:addRequest`
955
- // Sixth call is `AccountsController:getAccount`
956
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
1005
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 9 ) ;
957
1006
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
958
- 5 ,
1007
+ 6 ,
959
1008
'ApprovalController:addRequest' ,
960
1009
{
961
1010
id : requestId ,
@@ -1014,20 +1063,34 @@ describe('NftController', () => {
1014
1063
1015
1064
const callActionSpy = jest
1016
1065
. spyOn ( messenger , 'call' )
1066
+ // 1. `AccountsController:getAccount`
1067
+ . mockReturnValueOnce ( OWNER_ACCOUNT )
1068
+ // 2. `AssetsContractController:getERC721OwnerOf`
1069
+ . mockRejectedValueOnce ( new Error ( 'Not an ERC721 contract' ) )
1070
+ // 3. `AssetsContractController:getERC1155BalanceOf`
1071
+ . mockResolvedValueOnce ( new BN ( 1 ) )
1072
+ // 4. `AssetsContractController:getERC721TokenURI`
1073
+ . mockRejectedValueOnce ( new Error ( 'Not an ERC721 contract' ) )
1074
+ // 5. `AssetsContractController:getERC1155TokenURI`
1075
+ . mockResolvedValueOnce ( 'https://testtokenuri.com' )
1076
+ // 6. `ApprovalController:addRequest`
1077
+ . mockResolvedValueOnce ( { } )
1078
+ // 7. `AccountsController:getAccount`
1017
1079
. mockReturnValueOnce ( OWNER_ACCOUNT )
1018
- . mockResolvedValue ( { } ) ;
1080
+ // 8. `AssetsContractController:getERC1155AssetName`
1081
+ . mockResolvedValueOnce ( 'testERC1155Name' )
1082
+ // 9. `AssetsContractController:getERC1155AssetSymbol`
1083
+ . mockResolvedValueOnce ( 'testERC1155Symbol' ) ;
1019
1084
1020
1085
await nftController . watchNft (
1021
1086
ERC1155_NFT ,
1022
1087
ERC1155 ,
1023
1088
'https://etherscan.io' ,
1024
1089
) ;
1025
- // First call is `AccountsController:getAccount`
1026
- // Fifth call is `ApprovalController:addRequest`
1027
- // Sixth call is `AccountsController:getAccount`
1028
- expect ( callActionSpy ) . toHaveBeenCalledTimes ( 6 ) ;
1090
+
1091
+ expect ( callActionSpy ) . toHaveBeenCalledTimes ( 9 ) ;
1029
1092
expect ( callActionSpy ) . toHaveBeenNthCalledWith (
1030
- 5 ,
1093
+ 6 ,
1031
1094
'ApprovalController:addRequest' ,
1032
1095
{
1033
1096
id : requestId ,
0 commit comments