mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-08-15 18:45:06 +00:00
@@ -1,5 +1,20 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`modules/createDOMElement onClick 1`] = `
|
||||
Object {
|
||||
"_normalized": true,
|
||||
"changedTouches": Array [],
|
||||
"pageX": undefined,
|
||||
"pageY": undefined,
|
||||
"preventDefault": [Function],
|
||||
"stopImmediatePropagation": [Function],
|
||||
"stopPropagation": [Function],
|
||||
"target": undefined,
|
||||
"timestamp": 1496876171255,
|
||||
"touches": Array [],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`modules/createDOMElement prop "accessibilityLabel" 1`] = `
|
||||
<span
|
||||
aria-label="accessibilityLabel"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-env jasmine, jest */
|
||||
|
||||
import createDOMElement from '..';
|
||||
import { render } from 'enzyme';
|
||||
import { shallow, render } from 'enzyme';
|
||||
|
||||
describe('modules/createDOMElement', () => {
|
||||
test('renders correct DOM element', () => {
|
||||
@@ -103,6 +103,22 @@ describe('modules/createDOMElement', () => {
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('onClick', done => {
|
||||
const onClick = e => {
|
||||
e.nativeEvent.timestamp = 1496876171255;
|
||||
expect(e.nativeEvent).toMatchSnapshot();
|
||||
done();
|
||||
};
|
||||
const component = shallow(createDOMElement('span', { onClick }));
|
||||
component.find('span').simulate('click', {
|
||||
nativeEvent: {
|
||||
preventDefault() {},
|
||||
stopImmediatePropagation() {},
|
||||
stopPropagation() {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('prop "testID"', () => {
|
||||
const component = render(createDOMElement('span', { testID: 'Example.testID' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
|
||||
@@ -44,10 +44,11 @@ const createDOMElement = (component, props) => {
|
||||
|
||||
// normalize DOM events to match React Native events
|
||||
// TODO: move this out of the render path
|
||||
Object.keys(domProps).forEach(prop => {
|
||||
const isEventHandler = typeof prop === 'function' && eventHandlerNames[prop];
|
||||
Object.keys(domProps).forEach(propName => {
|
||||
const prop = domProps[propName];
|
||||
const isEventHandler = typeof prop === 'function' && eventHandlerNames[propName];
|
||||
if (isEventHandler) {
|
||||
domProps[prop] = wrapEventHandler(prop);
|
||||
domProps[propName] = wrapEventHandler(prop);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user