@ -1347,12 +1347,36 @@ describe('Send Slice', () => {
nickname : '' ,
nickname : '' ,
} ;
} ;
it ( 'should create an action to update recipient' , async ( ) => {
it ( 'should create actions to update recipient and recalculate gas limit if the asset type is not set' , async ( ) => {
global . eth = {
getCode : sinon . stub ( ) ,
} ;
const updateRecipientState = {
const updateRecipientState = {
metamask : {
provider : {
chainId : '0x1' ,
} ,
} ,
send : {
send : {
account : {
balance : '' ,
} ,
asset : {
asset : {
type : '' ,
type : '' ,
} ,
} ,
gas : {
gasPrice : '' ,
} ,
recipient : {
address : '' ,
} ,
amount : {
value : '' ,
} ,
draftTransaction : {
userInputHexData : '' ,
} ,
} ,
} ,
} ;
} ;
@ -1362,18 +1386,20 @@ describe('Send Slice', () => {
const actionResult = store . getActions ( ) ;
const actionResult = store . getActions ( ) ;
const expectedActionResult = [
expect ( actionResult ) . toHaveLength ( 4 ) ;
{
expect ( actionResult [ 0 ] . type ) . toStrictEqual ( 'send/updateRecipient' ) ;
type : 'send/updateRecipient' ,
expect ( actionResult [ 1 ] . type ) . toStrictEqual (
payload : recipient ,
'send/computeEstimatedGasLimit/pending' ,
} ,
) ;
] ;
expect ( actionResult [ 2 ] . type ) . toStrictEqual (
'metamask/gas/SET_CUSTOM_GAS_LIMIT' ,
expect ( actionResult ) . toHaveLength ( 1 ) ;
) ;
expect ( actionResult ) . toStrictEqual ( expectedActionResult ) ;
expect ( actionResult [ 3 ] . type ) . toStrictEqual (
'send/computeEstimatedGasLimit/fulfilled' ,
) ;
} ) ;
} ) ;
it ( 'should create actions to update recipient and recalculate gas limit if the asset is a token ' , async ( ) => {
it ( 'should create actions to reset recipient input and ens, calculate gas and then validate input ' , async ( ) => {
const tokenState = {
const tokenState = {
metamask : {
metamask : {
blockGasLimit : '' ,
blockGasLimit : '' ,
@ -1442,6 +1468,13 @@ describe('Send Slice', () => {
address : 'Address' ,
address : 'Address' ,
nickname : 'NickName' ,
nickname : 'NickName' ,
} ,
} ,
gas : {
gasPrice : '0x1' ,
} ,
amount : {
value : '0x1' ,
} ,
draftTransaction : { } ,
} ,
} ,
} ;
} ;
@ -1450,14 +1483,23 @@ describe('Send Slice', () => {
await store . dispatch ( resetRecipientInput ( ) ) ;
await store . dispatch ( resetRecipientInput ( ) ) ;
const actionResult = store . getActions ( ) ;
const actionResult = store . getActions ( ) ;
expect ( actionResult ) . toHaveLength ( 4 ) ;
expect ( actionResult ) . toHaveLength ( 7 ) ;
expect ( actionResult [ 0 ] . type ) . toStrictEqual (
expect ( actionResult [ 0 ] . type ) . toStrictEqual (
'send/updateRecipientUserInput' ,
'send/updateRecipientUserInput' ,
) ;
) ;
expect ( actionResult [ 0 ] . payload ) . toStrictEqual ( '' ) ;
expect ( actionResult [ 0 ] . payload ) . toStrictEqual ( '' ) ;
expect ( actionResult [ 1 ] . type ) . toStrictEqual ( 'send/updateRecipient' ) ;
expect ( actionResult [ 1 ] . type ) . toStrictEqual ( 'send/updateRecipient' ) ;
expect ( actionResult [ 2 ] . type ) . toStrictEqual ( 'ENS/resetEnsResolution' ) ;
expect ( actionResult [ 2 ] . type ) . toStrictEqual (
'send/computeEstimatedGasLimit/pending' ,
) ;
expect ( actionResult [ 3 ] . type ) . toStrictEqual (
expect ( actionResult [ 3 ] . type ) . toStrictEqual (
'metamask/gas/SET_CUSTOM_GAS_LIMIT' ,
) ;
expect ( actionResult [ 4 ] . type ) . toStrictEqual (
'send/computeEstimatedGasLimit/fulfilled' ,
) ;
expect ( actionResult [ 5 ] . type ) . toStrictEqual ( 'ENS/resetEnsResolution' ) ;
expect ( actionResult [ 6 ] . type ) . toStrictEqual (
'send/validateRecipientUserInput' ,
'send/validateRecipientUserInput' ,
) ;
) ;
} ) ;
} ) ;