mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 05:27:57 -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>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import {render} from '@testing-library/react-native';
|
|
import {DropdownIcon} from './DropdownIcon';
|
|
|
|
// Mock Popable
|
|
jest.mock('react-native-popable', () => ({
|
|
Popable: ({children}: {children: React.ReactNode}) => <>{children}</>,
|
|
}));
|
|
|
|
describe('DropdownIcon Component', () => {
|
|
const mockItems = [
|
|
{label: 'Item 1', onPress: jest.fn(), icon: 'account'},
|
|
{label: 'Item 2', onPress: jest.fn(), icon: 'settings'},
|
|
{label: 'Item 3', onPress: jest.fn(), icon: 'delete', idType: 'type1'},
|
|
];
|
|
|
|
const defaultProps = {
|
|
idType: 'type1',
|
|
icon: 'dots-vertical',
|
|
items: mockItems,
|
|
};
|
|
|
|
it('should match snapshot with default props', () => {
|
|
const {toJSON} = render(<DropdownIcon {...defaultProps} />);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with different icon', () => {
|
|
const {toJSON} = render(<DropdownIcon {...defaultProps} icon="menu" />);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with empty items', () => {
|
|
const {toJSON} = render(<DropdownIcon {...defaultProps} items={[]} />);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should match snapshot with multiple items', () => {
|
|
const manyItems = [
|
|
{label: 'Action 1', onPress: jest.fn(), icon: 'edit'},
|
|
{label: 'Action 2', onPress: jest.fn(), icon: 'share'},
|
|
{label: 'Action 3', onPress: jest.fn(), icon: 'download'},
|
|
{label: 'Action 4', onPress: jest.fn(), icon: 'upload'},
|
|
];
|
|
const {toJSON} = render(
|
|
<DropdownIcon {...defaultProps} items={manyItems} />,
|
|
);
|
|
expect(toJSON()).toMatchSnapshot();
|
|
});
|
|
});
|