Files
inji-wallet/components/BannerNotification.test.tsx
Kaushik Gupta d435a63468 INJIMOB-3246 Code coverage fix for failing test for new ui changes (#2126)
* INJIMOB-3246 Code coverage fix for failing test for new ui changes in develop branch

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Added build-inji-wallet job to run tests in push trigger workflow

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Updated actions/checkout from v3 to v4 for GitHub Actions compatibility

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Updated setup-node to v4 and added test-coverage step to CI workflow

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Updated actions/setup-node from v4 to v6.0.0 to move off deprecated Node16 runtime

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Removed unused env vars and redundant test-coverage step from build-inji-wallet job

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

* Renamed build-inji-wallet job to run-tests

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>

---------

Signed-off-by: Kaushik Gupta <kausgpt97@gmail.com>
2025-11-12 11:35:15 +05:30

57 lines
1.8 KiB
TypeScript

import React from 'react';
import {render} from '@testing-library/react-native';
import {BannerNotification, BannerStatusType} from './BannerNotification';
// Mock the SVG components
jest.mock('../assets/Error_Toast_Icon.svg', () => 'ErrorToastIcon');
jest.mock('../assets/Info_Toast_Icon.svg', () => 'InfoToastIcon');
jest.mock('../assets/Success_Toast_Icon.svg', () => 'SuccessToastIcon');
describe('BannerNotification Component', () => {
const defaultProps = {
message: 'Test notification message',
onClosePress: jest.fn(),
testId: 'bannerTest',
type: BannerStatusType.SUCCESS,
};
it('should match snapshot with success status', () => {
const {toJSON} = render(<BannerNotification {...defaultProps} />);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with error status', () => {
const {toJSON} = render(
<BannerNotification {...defaultProps} type={BannerStatusType.ERROR} />,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with in progress status', () => {
const {toJSON} = render(
<BannerNotification
{...defaultProps}
type={BannerStatusType.IN_PROGRESS}
/>,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with long message', () => {
const {toJSON} = render(
<BannerNotification
{...defaultProps}
message="This is a very long notification message that should wrap to multiple lines and still be displayed correctly"
/>,
);
expect(toJSON()).toMatchSnapshot();
});
it('should match snapshot with different testId', () => {
const {toJSON} = render(
<BannerNotification {...defaultProps} testId="customBanner" />,
);
expect(toJSON()).toMatchSnapshot();
});
});