You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flagon.apache.org by rf...@apache.org on 2019/09/26 00:11:46 UTC
[incubator-flagon-useralejs] 03/03: Fixed missing
window.sessionStorage. Added VirtualConsole to make future debugging easier
This is an automated email from the ASF dual-hosted git repository.
rf pushed a commit to branch FLAGON-434
in repository https://gitbox.apache.org/repos/asf/incubator-flagon-useralejs.git
commit 8e67a261f66a8dbaa17c17111169dc4389e2a8f9
Author: Rob Foley <ro...@gmail.com>
AuthorDate: Wed Sep 25 19:55:59 2019 -0400
Fixed missing window.sessionStorage. Added VirtualConsole to make future debugging easier
---
test/testUtils.js | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/test/testUtils.js b/test/testUtils.js
index 3581f92..ece0651 100644
--- a/test/testUtils.js
+++ b/test/testUtils.js
@@ -16,6 +16,7 @@
*/
import jsdom from 'jsdom';
import fs from 'fs';
+import Storage from 'dom-storage';
import { version } from '../package.json';
@@ -26,7 +27,7 @@ export function resourceLoader(res, callback) {
scriptContent = fs.readFileSync(`build/userale-${version}.min.js`).toString();
}
- const timeout = setTimeout(function() {
+ const timeout = setTimeout(() => {
callback(null, scriptContent);
}, 0);
@@ -39,16 +40,26 @@ export function resourceLoader(res, callback) {
}
export function createEnv(html, doneCallback, extraConfig) {
- let extra = (typeof extraConfig === 'undefined') ? {} : extraConfig;
+ const extra = (typeof extraConfig === 'undefined') ? {} : extraConfig;
+ const virtualConsole = jsdom.createVirtualConsole();
+ virtualConsole.sendTo(console);
return jsdom.env(Object.assign({}, {
- html : html,
- url : 'http://localhost:8080',
+ html: html,
+ url: 'http://localhost:8080',
features : {
FetchExternalResources : ['script'],
ProcessExternalResources : ['script']
},
resourceLoader,
- done : doneCallback,
+ created: (err, window) => {
+ if (err) {
+ throw err;
+ }
+
+ window.sessionStorage = new Storage(null, { strict: true });
+ },
+ done: doneCallback,
+ virtualConsole,
}, extraConfig));
}