mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
IPFS unit test for onboarding privacy setting (#18252)
This commit is contained in:
parent
ed3cc404f2
commit
00e6471d90
@ -246,6 +246,7 @@ export default function PrivacySettings() {
|
||||
<Box paddingTop={2}>
|
||||
<TextField
|
||||
style={{ width: '100%' }}
|
||||
inputProps={{ 'data-testid': 'ipfs-input' }}
|
||||
onChange={(e) => {
|
||||
handleIPFSChange(e.target.value);
|
||||
}}
|
||||
|
@ -23,6 +23,7 @@ describe('Privacy Settings Onboarding View', () => {
|
||||
const setUsePhishDetectStub = jest.fn();
|
||||
const setUseTokenDetectionStub = jest.fn();
|
||||
const setUseCurrencyRateCheckStub = jest.fn();
|
||||
const setIpfsGatewayStub = jest.fn();
|
||||
const completeOnboardingStub = jest
|
||||
.fn()
|
||||
.mockImplementation(() => Promise.resolve());
|
||||
@ -33,6 +34,7 @@ describe('Privacy Settings Onboarding View', () => {
|
||||
setUsePhishDetect: setUsePhishDetectStub,
|
||||
setUseTokenDetection: setUseTokenDetectionStub,
|
||||
setUseCurrencyRateCheck: setUseCurrencyRateCheckStub,
|
||||
setIpfsGateway: setIpfsGatewayStub,
|
||||
completeOnboarding: completeOnboardingStub,
|
||||
setUseMultiAccountBalanceChecker: setUseMultiAccountBalanceCheckerStub,
|
||||
});
|
||||
@ -95,4 +97,70 @@ describe('Privacy Settings Onboarding View', () => {
|
||||
);
|
||||
expect(setUseCurrencyRateCheckStub.mock.calls[1][0]).toStrictEqual(true);
|
||||
});
|
||||
|
||||
describe('IPFS', () => {
|
||||
it('should handle proper IPFS input', () => {
|
||||
const { queryByTestId, queryByText } = renderWithProvider(
|
||||
<PrivacySettings />,
|
||||
store,
|
||||
);
|
||||
|
||||
const ipfsInput = queryByTestId('ipfs-input');
|
||||
const ipfsEvent = {
|
||||
target: {
|
||||
value: 'ipfs.io',
|
||||
},
|
||||
};
|
||||
|
||||
fireEvent.change(ipfsInput, ipfsEvent);
|
||||
|
||||
const validIpfsUrl = queryByText('IPFS gateway URL is valid');
|
||||
expect(validIpfsUrl).toBeInTheDocument();
|
||||
|
||||
const submitButton = queryByText('Done');
|
||||
fireEvent.click(submitButton);
|
||||
|
||||
expect(setIpfsGatewayStub).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should error with gateway.ipfs.io IPFS input', () => {
|
||||
const { queryByTestId, queryByText } = renderWithProvider(
|
||||
<PrivacySettings />,
|
||||
store,
|
||||
);
|
||||
|
||||
const ipfsInput = queryByTestId('ipfs-input');
|
||||
const ipfsEvent = {
|
||||
target: {
|
||||
value: 'gateway.ipfs.io',
|
||||
},
|
||||
};
|
||||
|
||||
fireEvent.change(ipfsInput, ipfsEvent);
|
||||
|
||||
const invalidErrorMsg = queryByText('Please enter a valid URL');
|
||||
|
||||
expect(invalidErrorMsg).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should error with improper IPFS input', () => {
|
||||
const { queryByTestId, queryByText } = renderWithProvider(
|
||||
<PrivacySettings />,
|
||||
store,
|
||||
);
|
||||
|
||||
const ipfsInput = queryByTestId('ipfs-input');
|
||||
const ipfsEvent = {
|
||||
target: {
|
||||
value: ' ',
|
||||
},
|
||||
};
|
||||
|
||||
fireEvent.change(ipfsInput, ipfsEvent);
|
||||
|
||||
const invalidErrorMsg = queryByText('Please enter a valid URL');
|
||||
|
||||
expect(invalidErrorMsg).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user