diff options
Diffstat (limited to 'mascara/test')
-rw-r--r-- | mascara/test/helpers.js | 6 | ||||
-rw-r--r-- | mascara/test/index.js | 8 | ||||
-rw-r--r-- | mascara/test/test-ui.js | 2 | ||||
-rw-r--r-- | mascara/test/util/mascara-test-helper.js | 18 |
4 files changed, 17 insertions, 17 deletions
diff --git a/mascara/test/helpers.js b/mascara/test/helpers.js index eede103b4..8fc5c816b 100644 --- a/mascara/test/helpers.js +++ b/mascara/test/helpers.js @@ -1,6 +1,6 @@ -function wait(time) { - return new Promise(function(resolve, reject) { - setTimeout(function() { +export default function wait (time) { + return new Promise(function (resolve, reject) { + setTimeout(function () { resolve() }, time * 3 || 1500) }) diff --git a/mascara/test/index.js b/mascara/test/index.js index 0134cdf00..d62e43705 100644 --- a/mascara/test/index.js +++ b/mascara/test/index.js @@ -1,9 +1,9 @@ var fs = require('fs') var path = require('path') -var browserify = require('browserify'); +var browserify = require('browserify') var tests = fs.readdirSync(path.join(__dirname, 'lib')) var bundlePath = path.join(__dirname, 'test-bundle.js') -var b = browserify(); +var b = browserify() // Remove old bundle try { @@ -14,9 +14,9 @@ try { var writeStream = fs.createWriteStream(bundlePath) -tests.forEach(function(fileName) { +tests.forEach(function (fileName) { b.add(path.join(__dirname, 'lib', fileName)) }) -b.bundle().pipe(writeStream); +b.bundle().pipe(writeStream) diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js index b9bc42dff..16b2c206a 100644 --- a/mascara/test/test-ui.js +++ b/mascara/test/test-ui.js @@ -1,5 +1,3 @@ -const Helper = require('./util/mascara-test-helper.js') - window.addEventListener('load', () => { window.METAMASK_SKIP_RELOAD = true // inject app container diff --git a/mascara/test/util/mascara-test-helper.js b/mascara/test/util/mascara-test-helper.js index 9cf4fa900..0439fbba3 100644 --- a/mascara/test/util/mascara-test-helper.js +++ b/mascara/test/util/mascara-test-helper.js @@ -2,27 +2,29 @@ const EventEmitter = require('events') const IDB = require('idb-global') const KEY = 'metamask-test-config' module.exports = class Helper extends EventEmitter { - constructor () { - super() - } tryToCleanContext () { this.unregister() .then(() => this.clearDb()) .then(() => super.emit('complete')) - .catch((err) => super.emit('complete')) + .catch((err) => { + if (err) { + super.emit('complete') + } + }) } unregister () { return global.navigator.serviceWorker.getRegistration() .then((registration) => { - if (registration) return registration.unregister() + if (registration) { + return registration.unregister() .then((b) => b ? Promise.resolve() : Promise.reject()) - else return Promise.resolve() +} else return Promise.resolve() }) } clearDb () { - return new Promise ((resolve, reject) => { + return new Promise((resolve, reject) => { const deleteRequest = global.indexDB.deleteDatabase(KEY) deleteRequest.addEventListener('success', resolve) deleteRequest.addEventListener('error', reject) @@ -33,7 +35,7 @@ module.exports = class Helper extends EventEmitter { const db = new IDB({ version: 2, key: KEY, - initialState: state + initialState: state, }) return db.open() } |