Skip to content

Commit

Permalink
[core] Upgrade @mui/monorepo (mui#4149)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii authored Mar 10, 2022
1 parent 37766c8 commit 3a507bf
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
69 changes: 69 additions & 0 deletions test/utils/createDOM.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const { JSDOM } = require('jsdom');

// We can use jsdom-global at some point if maintaining these lists is a burden.
const whitelist = [
// used by React's experimental cache API
// Always including it to reduce churn when switching between React builds
'AbortController',
// required for fake getComputedStyle
'CSSStyleDeclaration',
'Element',
'Event',
'TouchEvent',
'Image',
'HTMLElement',
'HTMLInputElement',
'Node',
'Performance',
'document',
];
const blacklist = ['sessionStorage', 'localStorage'];

function createDOM() {
const dom = new JSDOM('', {
pretendToBeVisual: true,
});
global.window = dom.window;
// Not yet supported: https://github.com/jsdom/jsdom/issues/2152
class Touch {
constructor(instance) {
this.instance = instance;
}

get identifier() {
return this.instance.identifier;
}

get pageX() {
return this.instance.pageX;
}

get pageY() {
return this.instance.pageY;
}

get clientX() {
return this.instance.clientX;
}

get clientY() {
return this.instance.clientY;
}
}
global.window.Touch = Touch;

global.navigator = {
userAgent: 'node.js',
};

Object.keys(dom.window)
.filter((key) => !blacklist.includes(key))
.concat(whitelist)
.forEach((key) => {
if (typeof global[key] === 'undefined') {
global[key] = dom.window[key];
}
});
}

module.exports = createDOM;
2 changes: 1 addition & 1 deletion test/utils/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const formatUtil = require('format-util');
const Mocha = require('mocha');
const createDOM = require('@mui/monorepo/test/utils/createDOM');
const sinon = require('sinon');
const createDOM = require('./createDOM');

require('@babel/register')({
extensions: ['.js', '.ts', '.tsx'],
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2543,8 +2543,8 @@
react-transition-group "^4.4.2"

"@mui/monorepo@https://github.com/mui/material-ui.git#master":
version "5.4.4"
resolved "https://github.com/mui/material-ui.git#ee59e192a6cfb360604c75158d49d4657fe76d6b"
version "5.5.0"
resolved "https://github.com/mui/material-ui.git#98cd47bf4dd209fe1ba73c999c80d9a32a271889"

"@mui/private-theming@^5.4.4":
version "5.4.4"
Expand Down

0 comments on commit 3a507bf

Please sign in to comment.