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>
76 lines
1.9 KiB
TypeScript
76 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import {render} from '@testing-library/react-native';
|
|
import {VCVerification} from './VCVerification';
|
|
import {VCMetadata} from '../shared/VCMetadata';
|
|
import {Display} from './VC/common/VCUtils';
|
|
|
|
// Mock the Display class
|
|
const mockDisplay = {
|
|
getTextColor: jest.fn((defaultColor: string) => defaultColor),
|
|
} as unknown as Display;
|
|
|
|
describe('VCVerification Component', () => {
|
|
it('should render for verified and valid credential', () => {
|
|
const vcMetadata = new VCMetadata({
|
|
isVerified: true,
|
|
isExpired: false,
|
|
});
|
|
|
|
const {toJSON} = render(
|
|
<VCVerification vcMetadata={vcMetadata} display={mockDisplay} />,
|
|
);
|
|
|
|
expect(toJSON()).toBeTruthy();
|
|
});
|
|
|
|
it('should render for verified but expired credential', () => {
|
|
const vcMetadata = new VCMetadata({
|
|
isVerified: true,
|
|
isExpired: true,
|
|
});
|
|
|
|
const {toJSON} = render(
|
|
<VCVerification vcMetadata={vcMetadata} display={mockDisplay} />,
|
|
);
|
|
|
|
expect(toJSON()).toBeTruthy();
|
|
});
|
|
|
|
it('should render for pending/unverified credential', () => {
|
|
const vcMetadata = new VCMetadata({
|
|
isVerified: false,
|
|
isExpired: false,
|
|
});
|
|
|
|
const {toJSON} = render(
|
|
<VCVerification vcMetadata={vcMetadata} display={mockDisplay} />,
|
|
);
|
|
|
|
expect(toJSON()).toBeTruthy();
|
|
});
|
|
|
|
it('should render verification status text', () => {
|
|
const vcMetadata = new VCMetadata({
|
|
isVerified: true,
|
|
isExpired: false,
|
|
});
|
|
|
|
const {getByText} = render(
|
|
<VCVerification vcMetadata={vcMetadata} display={mockDisplay} />,
|
|
);
|
|
|
|
expect(getByText('valid')).toBeTruthy();
|
|
});
|
|
|
|
it('should call getTextColor from display prop', () => {
|
|
const vcMetadata = new VCMetadata({
|
|
isVerified: true,
|
|
isExpired: false,
|
|
});
|
|
|
|
render(<VCVerification vcMetadata={vcMetadata} display={mockDisplay} />);
|
|
|
|
expect(mockDisplay.getTextColor).toHaveBeenCalled();
|
|
});
|
|
});
|