Update jsdom to version 16.7.0
This commits updates jsdom to version 16.7.0. It also updates tests/javascript_newsletter_editor/mochaTestHelper.js to use the new jsdom API as the old API was removed. [MAILPOET-3678]
This commit is contained in:
1806
package-lock.json
generated
1806
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -153,7 +153,7 @@
|
|||||||
"inject-loader": "^4.0.1",
|
"inject-loader": "^4.0.1",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsdom": "^11.12.0",
|
"jsdom": "^16.7.0",
|
||||||
"json-loader": "^0.5.7",
|
"json-loader": "^0.5.7",
|
||||||
"lint-staged": "^11.0.0",
|
"lint-staged": "^11.0.0",
|
||||||
"mocha": "^7.2.0",
|
"mocha": "^7.2.0",
|
||||||
|
@@ -3,7 +3,7 @@ var sinon = require('sinon');
|
|||||||
var sinonChai = require('sinon-chai');
|
var sinonChai = require('sinon-chai');
|
||||||
var chaiJq = require('chai-jq');
|
var chaiJq = require('chai-jq');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var jsdom = require('jsdom/lib/old-api.js').jsdom;
|
var { JSDOM } = require('jsdom');
|
||||||
var URL = require('url').URL;
|
var URL = require('url').URL;
|
||||||
var nodeCrypto = require('crypto');
|
var nodeCrypto = require('crypto');
|
||||||
|
|
||||||
@@ -15,16 +15,17 @@ global.sinon = sinon;
|
|||||||
global.URL = URL;
|
global.URL = URL;
|
||||||
|
|
||||||
if (!global.document || !global.window) {
|
if (!global.document || !global.window) {
|
||||||
global.document = jsdom('<html><head><script></script></head><body></body></html>', {
|
global.document = new JSDOM(
|
||||||
|
'<html><head><script></script></head><body></body></html>',
|
||||||
|
{
|
||||||
url: 'http://example.com',
|
url: 'http://example.com',
|
||||||
}, {
|
runScripts: 'dangerously',
|
||||||
FetchExternalResources: ['script'],
|
resources: 'usable',
|
||||||
ProcessExternalResources: ['script'],
|
pretendToBeVisual: true,
|
||||||
MutationEvents: '2.0',
|
}
|
||||||
QuerySelector: false,
|
).window.document;
|
||||||
});
|
|
||||||
|
|
||||||
global.window = document.defaultView;
|
global.window = global.document.defaultView;
|
||||||
global.navigator = global.window.navigator;
|
global.navigator = global.window.navigator;
|
||||||
}
|
}
|
||||||
const testHelpers = require('./loadHelpers.js');
|
const testHelpers = require('./loadHelpers.js');
|
||||||
@@ -38,8 +39,9 @@ global._ = _;
|
|||||||
testHelpers.loadScript('tests/javascript_newsletter_editor/testBundles/vendor.js', global.window);
|
testHelpers.loadScript('tests/javascript_newsletter_editor/testBundles/vendor.js', global.window);
|
||||||
const Handlebars = global.window.Handlebars;
|
const Handlebars = global.window.Handlebars;
|
||||||
global.Handlebars = global.window.Handlebars;
|
global.Handlebars = global.window.Handlebars;
|
||||||
// Fix global access for Element. It is used in tinymce
|
// Fix global access for Element and Node. It is used in tinymce
|
||||||
global.Element = global.window.Element;
|
global.Element = global.window.Element;
|
||||||
|
global.Node = global.window.Node;
|
||||||
// Fix global access for HTMLAnchorElement. It is used in FileSaver
|
// Fix global access for HTMLAnchorElement. It is used in FileSaver
|
||||||
global.HTMLAnchorElement = global.window.HTMLAnchorElement;
|
global.HTMLAnchorElement = global.window.HTMLAnchorElement;
|
||||||
|
|
||||||
@@ -58,7 +60,6 @@ global.interact = function () {
|
|||||||
};
|
};
|
||||||
global.spectrum = function () { return this; };
|
global.spectrum = function () { return this; };
|
||||||
jQuery.fn.spectrum = global.spectrum;
|
jQuery.fn.spectrum = global.spectrum;
|
||||||
jQuery.fn.stick_in_parent = function () { return this; };
|
|
||||||
|
|
||||||
// Add global stubs for convenience
|
// Add global stubs for convenience
|
||||||
global.stubChannel = function (EditorApplication, returnObject) {
|
global.stubChannel = function (EditorApplication, returnObject) {
|
||||||
@@ -102,16 +103,6 @@ global.stubImage = function (defaultWidth, defaultHeight) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dummy Mutation Observer - needed for select2
|
|
||||||
// We will be able to remove this after upgrading to jsdom v13 or higher
|
|
||||||
global.window.MutationObserver = class {
|
|
||||||
constructor() { return null; }
|
|
||||||
|
|
||||||
disconnect() { return this; }
|
|
||||||
|
|
||||||
observe() { return this; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add simple polyfill for crypto
|
// Add simple polyfill for crypto
|
||||||
global.crypto = {
|
global.crypto = {
|
||||||
getRandomValues: (buffer) => nodeCrypto.randomFillSync(buffer),
|
getRandomValues: (buffer) => nodeCrypto.randomFillSync(buffer),
|
||||||
@@ -127,6 +118,8 @@ global.window.matchMedia = window.matchMedia || (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
global.window.fontsSelect = function () {};
|
||||||
|
|
||||||
testHelpers.loadTemplate('blocks/base/toolsGeneric.hbs', window, { id: 'newsletter_editor_template_tools_generic' });
|
testHelpers.loadTemplate('blocks/base/toolsGeneric.hbs', window, { id: 'newsletter_editor_template_tools_generic' });
|
||||||
|
|
||||||
testHelpers.loadTemplate('blocks/automatedLatestContentLayout/block.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_layout_block' });
|
testHelpers.loadTemplate('blocks/automatedLatestContentLayout/block.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_layout_block' });
|
||||||
|
Reference in New Issue
Block a user