aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mascara/src/ui.js9
-rw-r--r--mascara/test/test-ui.js13
-rw-r--r--mascara/test/window-load.js5
-rw-r--r--mock-dev.js1
-rw-r--r--package.json11
-rw-r--r--test/base.conf.js (renamed from karma.conf.js)6
-rw-r--r--test/mascara.conf.js14
-rw-r--r--test/together.conf.js8
8 files changed, 50 insertions, 17 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')
-})
diff --git a/mock-dev.js b/mock-dev.js
index b6652bdf7..452fe37c5 100644
--- a/mock-dev.js
+++ b/mock-dev.js
@@ -96,7 +96,6 @@ function startApp(){
const container = document.createElement('div')
container.id = 'app-content'
body.appendChild(container)
- console.log('container', container)
render(
h('.super-dev-container', [
diff --git a/package.json b/package.json
index d618983bd..8ba6e16cb 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"test": "npm run lint && npm run test-unit && npm run test-integration",
"test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"",
"single-test": "METAMASK_ENV=test mocha --require test/helper.js",
- "test-integration": "npm run buildMock && npm run buildCiUnits && karma start",
+ "test-integration": "npm run buildMock && npm run buildCiUnits && karma start test/together.conf.js",
"test-coverage": "nyc npm run test-unit && npm run coveralls-upload",
"coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi",
"ci": "npm run lint && npm run test-coverage && npm run test-integration",
@@ -27,10 +27,11 @@
"generateNotice": "node notices/notice-generator.js",
"deleteNotice": "node notices/notice-delete.js",
"mascara": "node ./mascara/example/server",
- "buildMascaraCi": "browserify mascara/test/window-load.js -o mascara/test/bundle.js",
- "buildMascaraSWCi": "browserify mascara/src/background.js -o mascara/test/background.js",
- "mascaraCi": "npm run buildMascaraCi && npm run buildMascaraSWCi && node mascara/test/index.js",
- "testMascara": "cd mascara/test && npm run mascaraCi && testem ci -P 3"
+ "testMascara": "npm run buildMascara && karma start test/mascara.conf.js",
+ "buildMascara": "npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests",
+ "buildMascaraUi": "browserify mascara/test/test-ui.js -o mascara/test/ui-bundle.js",
+ "buildMascaraBackground": "browserify mascara/src/background.js -o mascara/test/background.js",
+ "buildMascaraTests": "browserify test/integration/lib/first-time.js -o mascara/test/test-bundle.js"
},
"browserify": {
"transform": [
diff --git a/karma.conf.js b/test/base.conf.js
index 8e6d55972..122392822 100644
--- a/karma.conf.js
+++ b/test/base.conf.js
@@ -2,7 +2,7 @@
// Generated on Mon Sep 11 2017 18:45:48 GMT-0700 (PDT)
module.exports = function(config) {
- config.set({
+ return {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: process.cwd(),
@@ -16,9 +16,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
- 'development/bundle.js',
'test/integration/jquery-3.1.0.min.js',
- 'test/integration/bundle.js',
{ pattern: 'dist/chrome/images/**/*.*', watched: false, included: false, served: true },
{ pattern: 'dist/chrome/fonts/**/*.*', watched: false, included: false, served: true },
],
@@ -57,5 +55,5 @@ module.exports = function(config) {
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
- })
+ }
}
diff --git a/test/mascara.conf.js b/test/mascara.conf.js
new file mode 100644
index 000000000..8e8fa2cdf
--- /dev/null
+++ b/test/mascara.conf.js
@@ -0,0 +1,14 @@
+const getBaseConfig = require('./base.conf.js')
+
+module.exports = function(config) {
+ const settings = getBaseConfig(config)
+ settings.files.push('mascara/test/ui-bundle.js')
+ settings.files.push('mascara/test/test-bundle.js')
+ // settings.files.push('test/integration/bundle.js')
+ settings.files.push({ pattern: 'mascara/test/background.js', watched: false, included: false, served: true }),
+ // /background.js
+
+ settings.proxies['/background.js'] = '/base/mascara/test/background.js'
+
+ config.set(settings)
+}
diff --git a/test/together.conf.js b/test/together.conf.js
new file mode 100644
index 000000000..cd2dbdcdc
--- /dev/null
+++ b/test/together.conf.js
@@ -0,0 +1,8 @@
+const getBaseConfig = require('./base.conf.js')
+
+module.exports = function(config) {
+ const settings = getBaseConfig(config)
+ settings.files.push('development/bundle.js')
+ settings.files.push('test/integration/bundle.js')
+ config.set(settings)
+}