not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

  1. import _$ from 'jquery';
  2. import React from 'react';
  3. import ReactDOM from 'react-dom';
  4. import TestUtils from 'react-addons-test-utils';
  5. import jsdom from 'jsdom';
  6. import chai, { expect } from 'chai';
  7. import chaiJquery from 'chai-jquery';
  8. import { Provider } from 'react-redux';
  9. import { createStore } from 'redux';
  10. import reducers from '../src/reducers';
  11. global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
  12. global.window = global.document.defaultView;
  13. global.navigator = global.window.navigator;
  14. const $ = _$(window);
  15. chaiJquery(chai, chai.util, $);
  16. function renderComponent(ComponentClass, props = {}, state = {}) {
  17. const componentInstance = TestUtils.renderIntoDocument(
  18. <Provider store={createStore(reducers, state)}>
  19. <ComponentClass {...props} />
  20. </Provider>
  21. );
  22. return $(ReactDOM.findDOMNode(componentInstance));
  23. }
  24. $.fn.simulate = function(eventName, value) {
  25. if (value) {
  26. this.val(value);
  27. }
  28. TestUtils.Simulate[eventName](this[0]);
  29. };
  30. export {renderComponent, expect};