Skip to content

Instantly share code, notes, and snippets.

@klimnikova
Last active November 27, 2020 14:15
Show Gist options
  • Save klimnikova/44bb5b7d83560ee30196aee81a35f01e to your computer and use it in GitHub Desktop.
Save klimnikova/44bb5b7d83560ee30196aee81a35f01e to your computer and use it in GitHub Desktop.
import React from "react";
import renderer from "react-test-renderer";
import {offers} from "../test-mocks/offers-mocks";
import {CitiesList} from "../cities-list/cities-list";
import {Provider} from "react-redux";
import {Router} from "react-router-dom";
import configureStore from "redux-mock-store";
import browserHistory from "../../browser-history";
const noop = () => {};
const activeCard = {};
describe(`<CitiesList/> render`, () => {
const mockStore = configureStore([]);
let store = null;
beforeEach(() => {
store = mockStore({
DATA: {
offersAll: offers,
},
USER: {},
STATE: {
activeCard: {},
},
});
});
it(`renders correctly with full information`, () => {
const div = document.createElement(`div`);
div.id = `map`;
document.body.appendChild(div);
const citiesListComponent = renderer
.create(
<Provider store={store}>
<Router history={browserHistory}>
<CitiesList
offersCity={offers.slice(0, 2)}
offersAll={offers}
city={offers[0].city.name}
changeCity={noop}
activeCard={activeCard}
/>
</Router>
</Provider>
)
.toJSON();
expect(citiesListComponent).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment