import { mockFailureResponse } from '../../../mocks/server';
import {
  expectPageTestIds,
  expectPageTitle,
  expectRedirectedToLoginPage
} from '../../../utils/test/expects';
import FinancialPage, { FINANCIAL_PAGE_TITLE } from '../index';
import { renderWithClient } from '../../../utils/test/react-query';
import { createRouterWrapper } from '../../../utils/test/react-router-dom';
import App from '../../../App';
import { MemoryRouter } from 'react-router-dom';

describe('FinancialPage component', () => {
  test('successful render component', async () => {
    const result = renderWithClient(<FinancialPage />, MemoryRouter);
    await expectPageTitle(FINANCIAL_PAGE_TITLE);
    await expectPageTestIds(result);
  });

  test('redirect to login with not authenticated user', async () => {
    mockFailureResponse();
    const result = renderWithClient(<App />, createRouterWrapper('/home'));
    await expectRedirectedToLoginPage(result);
  });
});
