diff options
tests - start migrating mascara tests to karma
Diffstat (limited to 'mascara')
-rw-r--r-- | mascara/src/ui.js | 9 | ||||
-rw-r--r-- | mascara/test/test-ui.js | 13 | ||||
-rw-r--r-- | mascara/test/window-load.js | 5 |
3 files changed, 20 insertions, 7 deletions
diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 5f9be542f..5662270c1 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -44,13 +44,18 @@ background.on('ready', (sw) => { background.removeListener('updatefound', connectApp) connectApp(sw) }) -background.on('updatefound', () => window.location.reload()) +background.on('updatefound', windowReload) background.startWorker() .then(() => { setTimeout(() => { const appContent = document.getElementById(`app-content`) - if (!appContent.children.length) window.location.reload() + if (!appContent.children.length) windowReload() }, 2000) }) console.log('hello from MetaMascara ui!') + +function windowReload() { + if (window.METAMASK_SKIP_RELOAD) return + window.location.reload() +} diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js new file mode 100644 index 000000000..ebeffe8cb --- /dev/null +++ b/mascara/test/test-ui.js @@ -0,0 +1,13 @@ +const Helper = require('./util/mascara-test-helper.js') + +window.METAMASK_SKIP_RELOAD = true +window.addEventListener('load', () => { + // inject app container + const body = document.body + const container = document.createElement('div') + container.id = 'app-content' + body.appendChild(container) + + // start ui + require('../src/ui.js') +}) diff --git a/mascara/test/window-load.js b/mascara/test/window-load.js deleted file mode 100644 index d3f44f05f..000000000 --- a/mascara/test/window-load.js +++ /dev/null @@ -1,5 +0,0 @@ -const Helper = require('./util/mascara-test-helper.js') - -window.addEventListener('load', () => { - require('../src/ui.js') -}) |