import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import { NewsSingle } from 'app/modules/news/components/newsSingle';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-redux';


jest.mock('../store/news.selectors.ts', () => ({
  selectSingleLoadingStatus: jest.fn(() => false),
  selectNewsSingle: jest.fn(() => {
    return {
      id: 1,
      isActive: true,
      createdDate: '2011-01-01T00:00:00',
      publishDate: '4 June 1990',
      poolId: 52,
      author: 'John Doe',
      content: `<div>Content</div>`,
      summary: 'Summary',
      title: 'Title',
      leadingImage: undefined,
    };
  }),

}));

const initialState = {};

const mockStore = configureStore();

describe('News single component tests', () => {
  let store;

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

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

    expect(tree).toMatchSnapshot();
  });
});
