Skip to content

Commit

Permalink
Remove unused polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 5, 2020
1 parent 2ae909a commit 9ed4ecb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 44 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"eslint-plugin-react-hooks": "^4.0.7",
"expect-puppeteer": "^4.3.0",
"format-util": "^1.0.5",
"formdata-polyfill": "^3.0.20",
"fs-extra": "^9.0.0",
"glob": "^7.1.2",
"glob-gitignore": "^1.0.11",
Expand Down
3 changes: 0 additions & 3 deletions test/karma.tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// https://github.com/airbnb/enzyme/issues/1792
import 'core-js/modules/es6.array.from';
import 'formdata-polyfill';
import './utils/init';

const integrationContext = require.context(
Expand Down
40 changes: 5 additions & 35 deletions test/utils/createClientRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
act,
buildQueries,
cleanup,
createEvent,
fireEvent as rtlFireEvent,
queries,
render as testingLibraryRender,
Expand Down Expand Up @@ -157,10 +156,8 @@ export function createClientRender(globalOptions = {}) {
};
}

const fireEvent = Object.assign(rtlFireEvent, {
// polyfill event.key(Code) for chrome 49 and edge 15 (supported in Material-UI v4)
// for user-interactions react does the polyfilling but manually created
// events don't have this luxury
const fireEvent = {
...rtlFireEvent,
keyDown(element, options = {}) {
// `element` shouldn't be `document` but we catch this later anyway
const document = element.ownerDocument || element;
Expand All @@ -182,21 +179,7 @@ const fireEvent = Object.assign(rtlFireEvent, {
throw error;
}

const event = createEvent.keyDown(element, options);
Object.defineProperty(event, 'key', {
get() {
return options.key || '';
},
});
if (options.keyCode !== undefined && event.keyCode === 0) {
Object.defineProperty(event, 'keyCode', {
get() {
return options.keyCode;
},
});
}

rtlFireEvent(element, event);
rtlFireEvent.keyDown(element, options);
},
keyUp(element, options = {}) {
// `element` shouldn't be `document` but we catch this later anyway
Expand All @@ -218,23 +201,10 @@ const fireEvent = Object.assign(rtlFireEvent, {
.join('\n');
throw error;
}
const event = createEvent.keyUp(element, options);
Object.defineProperty(event, 'key', {
get() {
return options.key || '';
},
});
if (options.keyCode !== undefined && event.keyCode === 0) {
Object.defineProperty(event, 'keyCode', {
get() {
return options.keyCode;
},
});
}

rtlFireEvent(element, event);
rtlFireEvent.keyUp(element, options);
},
});
};

export * from '@testing-library/react/pure';
export { act, cleanup, fireEvent };
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7831,11 +7831,6 @@ format-util@^1.0.5:
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==

formdata-polyfill@^3.0.20:
version "3.0.20"
resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-3.0.20.tgz#d6319db8efc5cf4bb2da27856c2b902be63be1c6"
integrity sha512-TAaxIEwTBdoH1TWndtUH1T0/GisUHwmOKcV5hjkR/iTatHBJSOHb563FP86Lra5nXo3iNdhK7HPwMl5Ihg71pg==

forwarded@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
Expand Down

0 comments on commit 9ed4ecb

Please sign in to comment.