@ -611,6 +611,34 @@ describe('MetaMetricsController', function () {
describe ( '_buildUserTraitsObject' , function ( ) {
describe ( '_buildUserTraitsObject' , function ( ) {
it ( 'should return full user traits object on first call' , function ( ) {
it ( 'should return full user traits object on first call' , function ( ) {
const MOCK _ALL _TOKENS = {
'0x1' : {
'0x1235ce91d74254f29d4609f25932fe6d97bf4842' : [
{
address : '0xd2cea331e5f5d8ee9fb1055c297795937645de91' ,
} ,
{
address : '0xabc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9' ,
} ,
] ,
'0xe364b0f9d1879e53e8183055c9d7dd2b7375d86b' : [
{
address : '0xd2cea331e5f5d8ee9fb1055c297795937645de91' ,
} ,
] ,
} ,
'0x4' : {
'0x1235ce91d74254f29d4609f25932fe6d97bf4842' : [
{
address : '0xd2cea331e5f5d8ee9fb1055c297795937645de91' ,
} ,
{
address : '0x12317F958D2ee523a2206206994597C13D831ec7' ,
} ,
] ,
} ,
} ;
const metaMetricsController = getMetaMetricsController ( ) ;
const metaMetricsController = getMetaMetricsController ( ) ;
const traits = metaMetricsController . _buildUserTraitsObject ( {
const traits = metaMetricsController . _buildUserTraitsObject ( {
addressBook : {
addressBook : {
@ -643,6 +671,7 @@ describe('MetaMetricsController', function () {
] ,
] ,
} ,
} ,
} ,
} ,
allTokens : MOCK _ALL _TOKENS ,
frequentRpcListDetail : [
frequentRpcListDetail : [
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
@ -661,6 +690,7 @@ describe('MetaMetricsController', function () {
[ TRAITS . NFT _AUTODETECTION _ENABLED ] : false ,
[ TRAITS . NFT _AUTODETECTION _ENABLED ] : false ,
[ TRAITS . NUMBER _OF _ACCOUNTS ] : 2 ,
[ TRAITS . NUMBER _OF _ACCOUNTS ] : 2 ,
[ TRAITS . NUMBER _OF _NFT _COLLECTIONS ] : 3 ,
[ TRAITS . NUMBER _OF _NFT _COLLECTIONS ] : 3 ,
[ TRAITS . NUMBER _OF _TOKENS ] : 5 ,
[ TRAITS . OPENSEA _API _ENABLED ] : true ,
[ TRAITS . OPENSEA _API _ENABLED ] : true ,
[ TRAITS . THREE _BOX _ENABLED ] : false ,
[ TRAITS . THREE _BOX _ENABLED ] : false ,
} ) ;
} ) ;
@ -673,6 +703,7 @@ describe('MetaMetricsController', function () {
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
} ,
} ,
allTokens : { } ,
frequentRpcListDetail : [
frequentRpcListDetail : [
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
@ -689,6 +720,9 @@ describe('MetaMetricsController', function () {
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } , { address : '0x1' } ] ,
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } , { address : '0x1' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
} ,
} ,
allTokens : {
'0x1' : { '0xabcde' : [ { '0x12345' : { address : '0xtestAddress' } } ] } ,
} ,
frequentRpcListDetail : [
frequentRpcListDetail : [
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
@ -703,6 +737,7 @@ describe('MetaMetricsController', function () {
assert . deepEqual ( updatedTraits , {
assert . deepEqual ( updatedTraits , {
[ TRAITS . ADDRESS _BOOK _ENTRIES ] : 4 ,
[ TRAITS . ADDRESS _BOOK _ENTRIES ] : 4 ,
[ TRAITS . NUMBER _OF _ACCOUNTS ] : 3 ,
[ TRAITS . NUMBER _OF _ACCOUNTS ] : 3 ,
[ TRAITS . NUMBER _OF _TOKENS ] : 1 ,
[ TRAITS . OPENSEA _API _ENABLED ] : false ,
[ TRAITS . OPENSEA _API _ENABLED ] : false ,
} ) ;
} ) ;
} ) ;
} ) ;
@ -714,6 +749,7 @@ describe('MetaMetricsController', function () {
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
} ,
} ,
allTokens : { } ,
frequentRpcListDetail : [
frequentRpcListDetail : [
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
@ -730,6 +766,7 @@ describe('MetaMetricsController', function () {
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ MAINNET _CHAIN _ID ] : [ { address : '0x' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
[ ROPSTEN _CHAIN _ID ] : [ { address : '0x' } , { address : '0x0' } ] ,
} ,
} ,
allTokens : { } ,
frequentRpcListDetail : [
frequentRpcListDetail : [
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : MAINNET _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,
{ chainId : ROPSTEN _CHAIN _ID } ,