UNPKG

react-google-login

Version:
34 lines (23 loc) 875 B
import jsdom from 'jsdom'; import jquery from 'jquery'; import TestUtils from 'react-addons-test-utils'; import React from 'react'; import ReactDom from 'react-dom'; import chai, {expect} from 'chai'; import chaiJquery from 'chai-jquery'; global.document = jsdom.jsdom('<!doctype html><html><body></body><script></script></html>'); global.window = global.document.defaultView; const $ = jquery(global.window); function renderComponent(ComponentClass, props) { const component = ((children) => { return <ComponentClass {...props}/>; })(); const componentInstance = TestUtils.renderIntoDocument(component); return $(ReactDom.findDOMNode(componentInstance)); } $.fn.simulate = function (eventName, value) { if(value) this.val(value); TestUtils.Simulate[eventName](this[0]); }; chaiJquery(chai, chai.util, $); export {renderComponent, expect};