Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix edit network and delete network with tokenNetworkFilter #13141

Prev Previous commit
Next Next commit
fix: test
  • Loading branch information
sahar-fehri committed Jan 23, 2025
commit 9149e050e9f429265461a84cf9ad692bb7ea6953
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { mockNetworkState } from '../../../../../util/test/network';
import * as jsonRequest from '../../../../../util/jsonRpcRequest';
import Logger from '../../../../../util/Logger';
import Engine from '../../../../../core/Engine';
// eslint-disable-next-line import/no-namespace
import * as networks from '../../../../../util/networks';
const { PreferencesController } = Engine.context;

// Mock the entire module
jest.mock('../../../../../util/networks/isNetworkUiRedesignEnabled', () => ({
Expand Down Expand Up @@ -1775,6 +1778,44 @@ describe('NetworkSettings', () => {
}),
);
});

it('should not call setTokenNetworkFilter when portfolio view is disabled', async () => {
jest.spyOn(networks, 'isPortfolioViewEnabled').mockReturnValue(false);
const tokenNetworkFilterSpy = jest.spyOn(
PreferencesController,
'setTokenNetworkFilter',
);

wrapper.setState({
rpcUrl: 'http://localhost:8545',
chainId: '0x1',
ticker: 'ETH',
nickname: 'Localhost',
enableAction: true,
});

await wrapper.instance().addRpcUrl();
expect(tokenNetworkFilterSpy).toHaveBeenCalledTimes(0);
});

it('should call setTokenNetworkFilter when portfolio view is enabled', async () => {
jest.spyOn(networks, 'isPortfolioViewEnabled').mockReturnValue(true);
const tokenNetworkFilterSpy = jest.spyOn(
PreferencesController,
'setTokenNetworkFilter',
);

wrapper.setState({
rpcUrl: 'http://localhost:8545',
chainId: '0x1',
ticker: 'ETH',
nickname: 'Localhost',
enableAction: true,
});

await wrapper.instance().addRpcUrl();
expect(tokenNetworkFilterSpy).toHaveBeenCalledTimes(1);
});
});

describe('checkIfNetworkExists', () => {
Expand Down
Loading