Files
inji-wallet/components/DropdownIcon.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

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();
});
});