From 5ac86eda8e62772b5b5a02f68fc973982f3991d9 Mon Sep 17 00:00:00 2001 From: Shaheer Date: Mon, 7 Aug 2023 11:10:11 +0400 Subject: [PATCH] test: :test_tube: adds test case for app-notification --- .../app-notification-messages.spec.tsx | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 packages/core/src/App/Containers/__tests__/app-notification-messages.spec.tsx diff --git a/packages/core/src/App/Containers/__tests__/app-notification-messages.spec.tsx b/packages/core/src/App/Containers/__tests__/app-notification-messages.spec.tsx new file mode 100644 index 000000000000..3ebd425b6e10 --- /dev/null +++ b/packages/core/src/App/Containers/__tests__/app-notification-messages.spec.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import AppNotificationMessages from '../app-notification-messages'; + +jest.mock('Stores/connect', () => ({ + __esModule: true, + default: 'mockedDefaultExport', + connect: + () => + (Component: T) => + Component, +})); + +jest.mock('react-router-dom', () => ({ + useLocation: jest.fn(() => ({ + pathname: '/appstore/traders-hub', + })), +})); + +jest.mock('react-transition-group', () => ({ + TransitionGroup: jest.fn(({ children }) =>
{children}
), + CSSTransition: jest.fn(({ children }) =>
{children}
), +})); + +jest.mock('../../Components/Elements/NotificationMessage', () => jest.fn(() => 'mockedNotification')); + +describe('AppNotificationMessages', () => { + it('should render the component', () => { + const mock_props = { + marked_notifications: [], + notification_messages: [ + { + action: { + route: '/account/financial-assessment', + text: 'Start now', + }, + header: 'Pending action required', + key: 'notify_financial_assessment', + message: 'Please complete your financial assessment.', + should_show_again: true, + type: 'warning', + }, + ], + landing_company_shortcode: 'svg', + has_iom_account: false, + has_malta_account: false, + is_logged_in: true, + should_show_popups: true, + }; + render(); + expect(screen.getByText('mockedNotification')).toBeInTheDocument(); + }); +});