Skip to content

Instantly share code, notes, and snippets.

@Ranguro
Created January 31, 2019 22:25
Show Gist options
  • Save Ranguro/6f731edc267ffef038da654c70171494 to your computer and use it in GitHub Desktop.
Save Ranguro/6f731edc267ffef038da654c70171494 to your computer and use it in GitHub Desktop.
import React from 'react';
import { mount } from 'enzyme';
import { Plot } from '../<InsertDirHere>';
describe('Plot', () => {
describe('<Plot/> Component', () => {
const data = [];
const id = 'Chart_1';
const layout = {};
const afterDrawMock = jest.fn();
const props = { id, data, layout, afterDraw: afterDrawMock };
it('should call drawPlot method', () => {
console.log('Call sequence');
const spyDrawPlot = jest.spyOn(Plot.prototype, 'drawPlot');
console.log('Call after spying');
const wrapper = mount(<Plot {...props}></Plot>);
wrapper.instance().componentDidMount();
expect(spyDrawPlot).toHaveBeenCalled();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment