mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-29 09:08:32 +08:00
Update enzyme and don't use react-test-renderer
This commit is contained in:
@@ -78,7 +78,7 @@ exports[`modules/createDOMElement prop "accessible" 2`] = `<span />`;
|
||||
|
||||
exports[`modules/createDOMElement prop "accessible" 3`] = `
|
||||
<span
|
||||
aria-hidden={true}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,103 +1,99 @@
|
||||
/* eslint-env jasmine, jest */
|
||||
|
||||
import createDOMElement from '..';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { render } from 'enzyme';
|
||||
|
||||
describe('modules/createDOMElement', () => {
|
||||
test('renders correct DOM element', () => {
|
||||
let component = renderer.create(createDOMElement('span'));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
component = renderer.create(createDOMElement('main'));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
let component = render(createDOMElement('span'));
|
||||
expect(component).toMatchSnapshot();
|
||||
component = render(createDOMElement('main'));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('prop "accessibilityLabel"', () => {
|
||||
const accessibilityLabel = 'accessibilityLabel';
|
||||
const component = renderer.create(createDOMElement('span', { accessibilityLabel }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
const component = render(createDOMElement('span', { accessibilityLabel }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('prop "accessibilityLiveRegion"', () => {
|
||||
const accessibilityLiveRegion = 'none';
|
||||
const component = renderer.create(createDOMElement('span', { accessibilityLiveRegion }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
const component = render(createDOMElement('span', { accessibilityLiveRegion }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('prop "accessibilityRole"', () => {
|
||||
test('roles', () => {
|
||||
const component = renderer.create(createDOMElement('span', { accessibilityRole: 'banner' }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
const component = render(createDOMElement('span', { accessibilityRole: 'banner' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('button', () => {
|
||||
const component = renderer.create(createDOMElement('span', { accessibilityRole: 'button' }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
const component = render(createDOMElement('span', { accessibilityRole: 'button' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('headings', () => {
|
||||
let component = renderer.create(createDOMElement('div', { accessibilityRole: 'heading' }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
let component = render(createDOMElement('div', { accessibilityRole: 'heading' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
|
||||
component = renderer.create(
|
||||
component = render(
|
||||
createDOMElement('div', { accessibilityRole: 'heading', 'aria-level': '3' })
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('link and target="_blank"', () => {
|
||||
const component = renderer.create(
|
||||
const component = render(
|
||||
createDOMElement('span', {
|
||||
accessibilityRole: 'link',
|
||||
target: '_blank'
|
||||
})
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('compatibility with', () => {
|
||||
test('accessibilityComponentType', () => {
|
||||
let component = renderer.create(
|
||||
createDOMElement('span', { accessibilityComponentType: 'button' })
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
let component = render(createDOMElement('span', { accessibilityComponentType: 'button' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
|
||||
component = renderer.create(
|
||||
component = render(
|
||||
createDOMElement('span', {
|
||||
accessibilityComponentType: 'button',
|
||||
accessibilityRole: 'link'
|
||||
})
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('accessibilityTraits', () => {
|
||||
let component = renderer.create(
|
||||
createDOMElement('span', { accessibilityTraits: 'button' })
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
let component = render(createDOMElement('span', { accessibilityTraits: 'button' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
|
||||
component = renderer.create(
|
||||
component = render(
|
||||
createDOMElement('span', { accessibilityTraits: 'button', accessibilityRole: 'link' })
|
||||
);
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('prop "accessible"', () => {
|
||||
// accessible (implicit)
|
||||
let component = renderer.create(createDOMElement('span', {}));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
let component = render(createDOMElement('span', {}));
|
||||
expect(component).toMatchSnapshot();
|
||||
// accessible (explicit)
|
||||
component = renderer.create(createDOMElement('span', { accessible: true }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
component = render(createDOMElement('span', { accessible: true }));
|
||||
expect(component).toMatchSnapshot();
|
||||
// not accessible
|
||||
component = renderer.create(createDOMElement('span', { accessible: false }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
component = render(createDOMElement('span', { accessible: false }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('prop "testID"', () => {
|
||||
const component = renderer.create(createDOMElement('span', { testID: 'Example.testID' }));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
const component = render(createDOMElement('span', { testID: 'Example.testID' }));
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user