Skip to content

Commit 0743867

Browse files
committed
Remove enzyme
1 parent 331658f commit 0743867

File tree

9 files changed

+33
-393
lines changed

9 files changed

+33
-393
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
"caniuse-api": "^3.0.0",
4242
"cross-env": "^6.0.3",
4343
"del-cli": "^3.0.0",
44-
"enzyme": "^3.10.0",
45-
"enzyme-adapter-react-16": "^1.14.0",
46-
"enzyme-to-json": "^3.4.2",
4744
"eslint": "^6.5.1",
4845
"eslint-config-prettier": "^6.4.0",
4946
"eslint-plugin-promise": "^4.2.1",

packages/react-native-web/src/exports/ScrollView/__tests__/__snapshots__/index-test.js.snap

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,5 @@
11
/* eslint-env jasmine, jest */
22

3-
import React from 'react';
4-
import ScrollView from '..';
5-
import StyleSheet from '../../StyleSheet';
6-
import View from '../../View';
7-
import { mount, shallow } from 'enzyme';
8-
93
describe('components/ScrollView', () => {
10-
test('instance method setNativeProps', () => {
11-
const instance = mount(<ScrollView />).instance();
12-
expect(() => {
13-
instance.setNativeProps();
14-
}).not.toThrow();
15-
});
16-
17-
test('"children" prop', () => {
18-
const component = shallow(
19-
<ScrollView>
20-
<View testID="child" />
21-
</ScrollView>
22-
);
23-
expect(component.find({ testID: 'child' }).length).toBe(1);
24-
25-
component.setProps({ stickyHeaderIndices: [4] });
26-
expect(component.find({ testID: 'child' }).length).toBe(1);
27-
28-
component.setProps({ pagingEnabled: true });
29-
expect(component.find({ testID: 'child' }).length).toBe(1);
30-
});
31-
32-
test('"pagingEnabled" prop', () => {
33-
const getStyleProp = (component, prop) => StyleSheet.flatten(component.prop('style'))[prop];
34-
35-
// false
36-
const component = shallow(<ScrollView children={'Child'} />);
37-
expect(getStyleProp(component, 'scrollSnapType')).toMatchSnapshot();
38-
39-
// true
40-
component.setProps({ pagingEnabled: true });
41-
expect(getStyleProp(component, 'scrollSnapType')).toMatchSnapshot();
42-
expect(getStyleProp(component.children().childAt(0), 'scrollSnapAlign')).toMatchSnapshot();
43-
});
4+
test.skip('todo', () => {});
445
});

packages/react-native-web/src/exports/View/__tests__/index-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-env jasmine, jest */
22

33
import React from 'react';
4-
import { render } from '@testing-library/react';
54
import View from '../';
5+
import { render } from '@testing-library/react';
66

77
describe('components/View', () => {
88
test('default', () => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`modules/createElement renders different DOM elements 1`] = `<span />`;
3+
exports[`exports/createElement renders different DOM elements 1`] = `<span />`;
44

5-
exports[`modules/createElement renders different DOM elements 2`] = `<main />`;
5+
exports[`exports/createElement renders different DOM elements 2`] = `<main />`;

packages/react-native-web/src/exports/createElement/__tests__/index-test.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,39 @@
22

33
import createElement from '..';
44
import React from 'react';
5-
import { render, shallow } from 'enzyme';
5+
import { render } from '@testing-library/react';
66

7-
describe('modules/createElement', () => {
7+
describe('exports/createElement', () => {
88
test('renders different DOM elements', () => {
9-
let component = render(createElement('span'));
10-
expect(component).toMatchSnapshot();
11-
component = render(createElement('main'));
12-
expect(component).toMatchSnapshot();
9+
let { container } = render(createElement('span'));
10+
expect(container.firstChild).toMatchSnapshot();
11+
({ container } = render(createElement('main')));
12+
expect(container.firstChild).toMatchSnapshot();
1313
});
1414

1515
describe('prop "accessibilityRole"', () => {
16-
test('and string component type', () => {
17-
const component = shallow(createElement('span', { accessibilityRole: 'link' }));
18-
expect(component.find('a').length).toBe(1);
16+
test('string component type', () => {
17+
const { container } = render(createElement('span', { accessibilityRole: 'link' }));
18+
expect(container.firstChild.nodeName).toBe('A');
1919
});
2020

21-
test('and function component type', () => {
21+
test('function component type', () => {
2222
const Custom = () => <div />;
23-
const component = shallow(createElement(Custom, { accessibilityRole: 'link' }));
24-
expect(component.find('div').length).toBe(1);
23+
const { container } = render(createElement(Custom, { accessibilityRole: 'link' }));
24+
expect(container.firstChild.nodeName).toBe('DIV');
2525
});
2626

2727
const testRole = ({ accessibilityRole, disabled }) => {
2828
[{ key: 'Enter' }, { key: ' ' }].forEach(({ key }) => {
2929
test(`"onClick" is ${disabled ? 'not ' : ''}called when "${key}" key is pressed`, () => {
3030
const onClick = jest.fn();
31-
const component = shallow(
31+
const { container } = render(
3232
createElement('span', { accessibilityRole, disabled, onClick })
3333
);
34-
component.find('span').simulate('keyPress', {
35-
isDefaultPrevented() {},
36-
nativeEvent: {},
37-
preventDefault() {},
38-
key
39-
});
34+
const event = document.createEvent('CustomEvent');
35+
event.initCustomEvent('keydown', true, true);
36+
event.key = key;
37+
container.firstChild.dispatchEvent(event);
4038
expect(onClick).toHaveBeenCalledTimes(disabled ? 0 : 1);
4139
});
4240
});

scripts/jest/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module.exports = {
1212
roots: ['<rootDir>/packages'],
1313
setupFiles: ['jest-canvas-mock', require.resolve('./setupFiles.js')],
1414
setupFilesAfterEnv: [require.resolve('./setupFramework.js')],
15-
snapshotSerializers: ['enzyme-to-json/serializer'],
1615
testEnvironment: 'jsdom',
1716
timers: 'fake'
1817
};

scripts/jest/setupFramework.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
11
/* eslint-env jasmine, jest */
2-
3-
import Adapter from 'enzyme-adapter-react-16';
4-
import Enzyme from 'enzyme';
5-
import serializer from './serializer';
6-
7-
Enzyme.configure({ adapter: new Adapter() });
8-
9-
// TODO: move off legacy serializer
10-
expect.addSnapshotSerializer(serializer);

0 commit comments

Comments
 (0)