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}>
|
<Box paddingTop={2}>
|
||||||
<TextField
|
<TextField
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
|
inputProps={{ 'data-testid': 'ipfs-input' }}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
handleIPFSChange(e.target.value);
|
handleIPFSChange(e.target.value);
|
||||||
}}
|
}}
|
||||||
|
@ -23,6 +23,7 @@ describe('Privacy Settings Onboarding View', () => {
|
|||||||
const setUsePhishDetectStub = jest.fn();
|
const setUsePhishDetectStub = jest.fn();
|
||||||
const setUseTokenDetectionStub = jest.fn();
|
const setUseTokenDetectionStub = jest.fn();
|
||||||
const setUseCurrencyRateCheckStub = jest.fn();
|
const setUseCurrencyRateCheckStub = jest.fn();
|
||||||
|
const setIpfsGatewayStub = jest.fn();
|
||||||
const completeOnboardingStub = jest
|
const completeOnboardingStub = jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockImplementation(() => Promise.resolve());
|
.mockImplementation(() => Promise.resolve());
|
||||||
@ -33,6 +34,7 @@ describe('Privacy Settings Onboarding View', () => {
|
|||||||
setUsePhishDetect: setUsePhishDetectStub,
|
setUsePhishDetect: setUsePhishDetectStub,
|
||||||
setUseTokenDetection: setUseTokenDetectionStub,
|
setUseTokenDetection: setUseTokenDetectionStub,
|
||||||
setUseCurrencyRateCheck: setUseCurrencyRateCheckStub,
|
setUseCurrencyRateCheck: setUseCurrencyRateCheckStub,
|
||||||
|
setIpfsGateway: setIpfsGatewayStub,
|
||||||
completeOnboarding: completeOnboardingStub,
|
completeOnboarding: completeOnboardingStub,
|
||||||
setUseMultiAccountBalanceChecker: setUseMultiAccountBalanceCheckerStub,
|
setUseMultiAccountBalanceChecker: setUseMultiAccountBalanceCheckerStub,
|
||||||
});
|
});
|
||||||
@ -95,4 +97,70 @@ describe('Privacy Settings Onboarding View', () => {
|
|||||||
);
|
);
|
||||||
expect(setUseCurrencyRateCheckStub.mock.calls[1][0]).toStrictEqual(true);
|
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…
x
Reference in New Issue
Block a user