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

100 lines
2.7 KiB
TypeScript

import React from 'react';
import {render} from '@testing-library/react-native';
import {MessageOverlay, ErrorMessageOverlay} from './MessageOverlay';
import {Text} from 'react-native';
// Mock react-native-elements
jest.mock('react-native-elements', () => ({
Overlay: ({children}: {children: React.ReactNode}) => <>{children}</>,
LinearProgress: jest.fn(() => null),
}));
// Mock ui components
jest.mock('./ui', () => ({
Button: jest.fn(() => null),
Column: ({children}: {children: React.ReactNode}) => <>{children}</>,
Text: ({children}: {children: React.ReactNode}) => <>{children}</>,
}));
describe('MessageOverlay Component', () => {
const defaultProps = {
isVisible: true,
title: 'Test Title',
message: 'Test Message',
};
it('should match snapshot with title and message', () => {
const {toJSON} = render(<MessageOverlay {...defaultProps} />);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with progress indicator', () => {
const {toJSON} = render(
<MessageOverlay {...defaultProps} progress={true} />,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with numeric progress', () => {
const {toJSON} = render(
<MessageOverlay {...defaultProps} progress={0.75} />,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with button', () => {
const {toJSON} = render(
<MessageOverlay
{...defaultProps}
buttonText="OK"
onButtonPress={jest.fn()}
/>,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with custom children', () => {
const {toJSON} = render(
<MessageOverlay {...defaultProps}>
<Text>Custom Content</Text>
</MessageOverlay>,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with hint text', () => {
const {toJSON} = render(
<MessageOverlay {...defaultProps} hint="This is a hint" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with custom minHeight', () => {
const {toJSON} = render(
<MessageOverlay {...defaultProps} minHeight={250} />,
);
expect(toJSON()).toMatchSnapshot();
});
});
describe('ErrorMessageOverlay Component', () => {
const errorProps = {
isVisible: true,
error: 'network',
translationPath: 'errors',
onDismiss: jest.fn(),
};
it('should match snapshot with error', () => {
const {toJSON} = render(<ErrorMessageOverlay {...errorProps} />);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with testID', () => {
const {toJSON} = render(
<ErrorMessageOverlay {...errorProps} testID="errorOverlay" />,
);
expect(toJSON()).toMatchSnapshot();
});
});