import { ForecastPoolPage } from './forecastPool.page';
import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';

jest.mock('app/modules/markets/store/markets.selectors', () => ({
  createMarketsIsLoadingSelector: jest.fn(() => () => false),
  selectIsMoreComments: jest.fn(() => false),
  selectOrderedComments: jest.fn(() => [
    {
      id: 1,
      publishDate: 'date 1',
      relevantDate: 'date 1',
      comment: 'comment 1',
    },
    {
      id: 2,
      publishDate: 'date 2',
      relevantDate: 'date 2',
      comment: 'comment 2',
    },
  ]),
  createMarketsErrorStatusSelector: jest.fn(() => () => false),
  selectProgressBarExposures: jest.fn(() => ({
    pool: [ 13, 7 ],
    market: [ 1, 2 ],
    legend: [ 'market 1', 'market2' ],
  })),
  selectHasImoCargoInExposure: jest.fn(() => true),
}));

jest.mock('app/modules/forecast/store/forecast.selectors', () => ({
  selectKeyValues: jest.fn(() => ({
    selectedMonth: 'last month',
    lastUpdateDate: 'update date',
    value:  13000,
    fixedPercentage: 77,
    unfixedPercentage: 23,
    fixedRate: 10010,
    unfixedRate: 2990,
    payoutRatio: 100,
  })),
}));

describe('ForecastPool page tests', () => {
  const mockStore = configureStore();
  let store;

  beforeEach(() => {
    store = mockStore({});
  });

  it('renders page correctly', () => {
    const tree = ReactTestRenderer
      .create(<Provider store={store}>
        <MemoryRouter>
          <ForecastPoolPage />
        </MemoryRouter>
      </Provider>)
      .toJSON();
    expect(tree).toMatchSnapshot();
  });
});
