EventPluginHub-test.jsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import ReactTestUtils from "../../lib/ReactTestUtils";
  2. import React from '../../src/May';
  3. import { render, unmountComponentAtNode } from '../../src/may-dom/MayDom'
  4. var ReactDOM = {
  5. render: render,
  6. unmountComponentAtNode: unmountComponentAtNode
  7. }
  8. React.render = render;
  9. import {
  10. dispatchEvent, SyntheticEvent, addEvent
  11. } from '../../src/event';
  12. // import React from "../../dist/ReactANU";
  13. // var ReactDOM = React;
  14. // var ReactTestUtils = { Simulate: {} };
  15. // "click,change,keyDown,keyUp,KeyPress,mouseDown,mouseUp,mouseMove".replace(/\w+/g, function (name) {
  16. // ReactTestUtils.Simulate[name] = function (node, opts) {
  17. // if (!node || node.nodeType !== 1) {
  18. // throw "第一个参数必须为元素节点";
  19. // }
  20. // var fakeNativeEvent = opts || {};
  21. // fakeNativeEvent.target = node;
  22. // fakeNativeEvent.simulated = true;
  23. // fakeNativeEvent.type = name.toLowerCase();
  24. // React.eventSystem.dispatchEvent(fakeNativeEvent, name.toLowerCase());
  25. // };
  26. // });
  27. // https://github.com/facebook/react/blob/master/src/renderers/__tests__/EventPluginHub-test.js
  28. // 已测试
  29. describe("isEventSupported", function() {
  30. // this.timeout(200000);
  31. /*it('should prevent non-function listeners, at dispatch', () => {
  32. spyOn(console, 'error');
  33. var node = ReactTestUtils.renderIntoDocument(
  34. <div onClick="not a function" />,
  35. );
  36. expect(function() {
  37. ReactTestUtils.Simulate.click(node);
  38. }).toThrowError(
  39. 'Expected `onClick` listener to be a function, instead got a value of `string` type.',
  40. );
  41. });
  42. it('should not prevent null listeners, at dispatch', () => {
  43. var node = ReactTestUtils.renderIntoDocument(<div onClick={null} />);
  44. expect(function() {
  45. ReactTestUtils.Simulate.click(node);
  46. }).not.toThrow('Expected `onClick` listener to be a function, instead got a value of `null` type.');
  47. });*/
  48. });