From 2bb875d56f8b9c81eda04040e365966cb72c744f Mon Sep 17 00:00:00 2001 From: salimtb Date: Wed, 16 Oct 2024 16:16:55 +0200 Subject: [PATCH] fix: increase test coverage --- .../NetworkSettings/index.test.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.test.tsx b/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.test.tsx index b17ad4b0286..a04a93b43c5 100644 --- a/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.test.tsx +++ b/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.test.tsx @@ -866,6 +866,32 @@ describe('NetworkSettings', () => { expect(instance.state.warningSymbol).toBeUndefined(); // No warning for valid symbol }); + + it('should validateChainIdOnSubmit', async () => { + const instance = wrapper.instance(); + + const validChainId = '0x38'; + + await instance.validateChainIdOnSubmit( + validChainId, + validChainId, + 'https://bsc-dataseed.binance.org/', + ); + + expect(instance.state.warningChainId).toBeUndefined(); + }); + + it('should set a warning when chainId is not valid', async () => { + const instance = wrapper.instance(); + + const validChainId = '0xInvalidChainId'; + + await instance.validateChainIdOnSubmit(validChainId); + + expect(instance.state.warningChainId).toBe( + 'Could not fetch chain ID. Is your RPC URL correct?', + ); + }); }); describe('NetworkSettings componentDidMount', () => {