mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-08 05:03:56 -05:00
* 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>
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import {render} from '@testing-library/react-native';
|
|
import {Passcode} from './Passcode';
|
|
|
|
// Mock PasscodeVerify
|
|
jest.mock('./PasscodeVerify', () => ({
|
|
PasscodeVerify: jest.fn(() => null),
|
|
}));
|
|
|
|
// Mock telemetry
|
|
jest.mock('../shared/telemetry/TelemetryUtils', () => ({
|
|
getImpressionEventData: jest.fn(),
|
|
sendImpressionEvent: jest.fn(),
|
|
}));
|
|
|
|
describe('Passcode Component', () => {
|
|
const defaultProps = {
|
|
error: '',
|
|
storedPasscode: 'hashed-passcode',
|
|
salt: 'salt-value',
|
|
onSuccess: jest.fn(),
|
|
onError: jest.fn(),
|
|
onDismiss: jest.fn(),
|
|
};
|
|
|
|
it('should match snapshot with default props', () => {
|
|
const {toJSON} = render(<Passcode {...defaultProps} />);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with custom message', () => {
|
|
const {toJSON} = render(
|
|
<Passcode
|
|
{...defaultProps}
|
|
message="Please enter your 6-digit passcode"
|
|
/>,
|
|
);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with error message', () => {
|
|
const {toJSON} = render(
|
|
<Passcode {...defaultProps} error="Incorrect passcode. Try again." />,
|
|
);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with both message and error', () => {
|
|
const {toJSON} = render(
|
|
<Passcode
|
|
{...defaultProps}
|
|
message="Enter passcode"
|
|
error="Authentication failed"
|
|
/>,
|
|
);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
});
|