Skip to content

Instantly share code, notes, and snippets.

@magsout
Created March 26, 2018 12:49
Show Gist options
  • Save magsout/f77d5dc6fb5c997c47824f19b7f126f8 to your computer and use it in GitHub Desktop.
Save magsout/f77d5dc6fb5c997c47824f19b7f126f8 to your computer and use it in GitHub Desktop.
import "../../../../scripts/test-setup.js"
import React from "react";
import renderer from "react-test-renderer";
import sinon from "sinon";
import {shallow} from "enzyme";
import { BrowserRouter as Router } from "react-router-dom";
import Header from "../";
it("renders Header default correctly", () => {
const tree = renderer.create(
<Router><Header /></Router>
).toJSON();
expect(tree).toMatchSnapshot();
});
it('Header click button', () => {
const onClick = sinon.spy();
const wrapper = shallow(<Header onClick={onClick} />);
wrapper.find('button').simulate('click');
expect(onClick.calledOnce).toEqual(true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment