Files
inji-wallet/components/PasscodeVerify.test.tsx
Kaushik Gupta 33c6caa08a INJIMOB-3246 Code coverage for Inji-Wallet repo increase above 5% (#2108)
* INJIMOB-3246 Code coverage for Inji-Wallet repo increase above 5%

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* INJIMOB-3246: added snapshot tests and coverage increased to +4%

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* removed duplicated lines

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Added updateCredentialInformation tests

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* added code rabbit changes

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* removed platform-specific tests without mocking

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* standardize mocks in VcItemContainerProfileImage tests

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

---------

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>
2025-11-07 11:10:37 +05:30

55 lines
1.4 KiB
TypeScript

import React from 'react';
import {render} from '@testing-library/react-native';
import {PasscodeVerify} from './PasscodeVerify';
// Mock PinInput
jest.mock('./PinInput', () => ({
PinInput: jest.fn(() => null),
}));
// Mock commonUtil
jest.mock('../shared/commonUtil', () => ({
hashData: jest.fn(() => Promise.resolve('hashed-value')),
}));
// Mock telemetry
jest.mock('../shared/telemetry/TelemetryUtils', () => ({
getErrorEventData: jest.fn(),
sendErrorEvent: jest.fn(),
}));
describe('PasscodeVerify Component', () => {
const defaultProps = {
passcode: 'stored-hashed-passcode',
onSuccess: jest.fn(),
onError: jest.fn(),
salt: 'test-salt',
testID: 'passcodeVerify',
};
it('should match snapshot with default props', () => {
const {toJSON} = render(<PasscodeVerify {...defaultProps} />);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with different testID', () => {
const {toJSON} = render(
<PasscodeVerify {...defaultProps} testID="customPasscode" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot without onError handler', () => {
const {passcode, onSuccess, salt, testID} = defaultProps;
const {toJSON} = render(
<PasscodeVerify
passcode={passcode}
onSuccess={onSuccess}
salt={salt}
testID={testID}
/>,
);
expect(toJSON()).toMatchSnapshot();
});
});