Skip to content

Commit

Permalink
test: 🧪 adds test case for app-notification
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheer-deriv committed Aug 7, 2023
1 parent 85c695e commit 5ac86ed
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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:
() =>
<T,>(Component: T) =>
Component,
}));

jest.mock('react-router-dom', () => ({
useLocation: jest.fn(() => ({
pathname: '/appstore/traders-hub',
})),
}));

jest.mock('react-transition-group', () => ({
TransitionGroup: jest.fn(({ children }) => <div>{children}</div>),
CSSTransition: jest.fn(({ children }) => <div>{children}</div>),
}));

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(<AppNotificationMessages {...mock_props} />);
expect(screen.getByText('mockedNotification')).toBeInTheDocument();
});
});

0 comments on commit 5ac86ed

Please sign in to comment.