Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom events #2

Closed
wants to merge 11 commits into from
Closed

Custom events #2

wants to merge 11 commits into from

Conversation

nhunzaker
Copy link
Owner

@nhunzaker nhunzaker commented Oct 23, 2016

Supports custom events in addition to custom attributes:

  • Most events are generated on the fly as needed. Whenever an unrecognized event is discovered, it generates a registration for it.
  • This means most of the big lists of event names can go away, but I'm leaning on the top level event constants more (though I wonder if that could go away too)
  • Testing custom events is sort of a drag, so I made ReactTestUtils.Simulate into a function, which accepts a custom event name
    it('simulated custom events capture', () => {
      var callback = jest.fn();

      var el = ReactTestUtils.renderIntoDocument((
        <div onCustomCapture={() => callback('capture')}>
          <button onCustom={() => callback('bubble')} />
        </div>
      ));

      ReactTestUtils.Simulate('custom', el.querySelector('button'));

      var sequence = callback.mock.calls.map(args => args[0]);

      expect(sequence).toEqual(['capture', 'bubble']);
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant