@ -78,7 +78,13 @@ describe('NetworkForm Component', () => {
encodedQueryParams : true ,
encodedQueryParams : true ,
} )
} )
. post ( '/' )
. post ( '/' )
. reply ( 200 , { jsonrpc : '2.0' , id : '1643927040523' , result : '0x38' } ) ;
. reply ( 200 , { jsonrpc : '2.0' , result : '0x38' } ) ;
nock ( 'https://rpc.flashbots.net:443' , {
encodedQueryParams : true ,
} )
. post ( '/' )
. reply ( 200 , { jsonrpc : '2.0' , result : '0x1' } ) ;
} ) ;
} ) ;
afterEach ( ( ) => {
afterEach ( ( ) => {
@ -190,17 +196,30 @@ describe('NetworkForm Component', () => {
renderComponent ( propNewNetwork ) ;
renderComponent ( propNewNetwork ) ;
const chainIdField = screen . getByRole ( 'textbox' , { name : 'Chain ID' } ) ;
const chainIdField = screen . getByRole ( 'textbox' , { name : 'Chain ID' } ) ;
const rpcUrlField = screen . getByRole ( 'textbox' , { name : 'New RPC URL' } ) ;
const rpcUrlField = screen . getByRole ( 'textbox' , { name : 'New RPC URL' } ) ;
const currencySymbolField = screen . getByRole ( 'textbox' , {
name : 'Currency symbol' ,
} ) ;
fireEvent . change ( chainIdField , {
fireEvent . change ( chainIdField , {
target : { value : '1' } ,
target : { value : '1' } ,
} ) ;
} ) ;
fireEvent . change ( currencySymbolField , {
target : { value : 'test' } ,
} ) ;
fireEvent . change ( rpcUrlField , {
target : { value : 'https://rpc.flashbots.net' } ,
} ) ;
expect (
expect (
await screen . findByText (
await screen . findByText (
'This Chain ID is currently used by the mainnet network.' ,
'This Chain ID is currently used by the mainnet network.' ,
) ,
) ,
) . toBeInTheDocument ( ) ;
) . toBeInTheDocument ( ) ;
expect ( screen . getByText ( 'Save' ) ) . not . toBeDisabled ( ) ;
fireEvent . change ( rpcUrlField , {
fireEvent . change ( rpcUrlField , {
target : { value : 'https://bsc-dataseed.binance.org/' } ,
target : { value : 'https://bsc-dataseed.binance.org/' } ,
} ) ;
} ) ;
@ -209,6 +228,8 @@ describe('NetworkForm Component', () => {
'The RPC URL you have entered returned a different chain ID (56). Please update the Chain ID to match the RPC URL of the network you are trying to add.' ;
'The RPC URL you have entered returned a different chain ID (56). Please update the Chain ID to match the RPC URL of the network you are trying to add.' ;
expect ( await screen . findByText ( expectedWarning ) ) . toBeInTheDocument ( ) ;
expect ( await screen . findByText ( expectedWarning ) ) . toBeInTheDocument ( ) ;
expect ( screen . getByText ( 'Save' ) ) . toBeDisabled ( ) ;
fireEvent . change ( chainIdField , {
fireEvent . change ( chainIdField , {
target : { value : 'a' } ,
target : { value : 'a' } ,
} ) ;
} ) ;