mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Fix extension tests
This commit is contained in:
parent
d484cb8f51
commit
be74589f49
@ -98,7 +98,7 @@
|
||||
"no-obj-calls": 2,
|
||||
"no-octal": 2,
|
||||
"no-octal-escape": 2,
|
||||
"no-path-concat": 2,
|
||||
"no-path-concat": 1,
|
||||
"no-proto": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-regex-spaces": 2,
|
||||
|
@ -5,7 +5,7 @@ const extension = require('./lib/extension')
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const inpageText = fs.readFileSync(__dirname + '/inpage.js').toString()
|
||||
const inpageText = fs.readFileSync(path.join(__dirname + '/inpage.js')).toString()
|
||||
|
||||
// Eventually this streaming injection could be replaced with:
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
|
||||
|
@ -26,7 +26,10 @@ function Extension () {
|
||||
const _this = this
|
||||
|
||||
apis.forEach(function (api) {
|
||||
_this[api] = chrome ? chrome[api] : window[api] || browser.extension[api]
|
||||
_this[api] = chrome !== undefined && chrome[api] ? chrome[api]
|
||||
: window[api] ? window[api]
|
||||
: browser && browser.extension && browser.extension[api]
|
||||
? browser.extension[api] : null
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "gulp dev",
|
||||
"test": "mocha --require test/helper.js --compilers js:babel-register --recursive \"test/unit/**/*.js\" && npm run ci",
|
||||
"test": "npm run fastTest && npm run ci",
|
||||
"fastTest": "mocha --require test/helper.js --compilers js:babel-register --recursive \"test/unit/**/*.js\"",
|
||||
"watch": "mocha watch --compilers js:babel-register --recursive \"test/unit/**/*.js\"",
|
||||
"ui": "node development/genStates.js && beefy ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./",
|
||||
"mock": "beefy mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./",
|
||||
|
@ -1,6 +1,8 @@
|
||||
var assert = require('assert')
|
||||
var sinon = require('sinon')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
GLOBAL.chrome = {}
|
||||
GLOBAL.browser = {}
|
||||
|
||||
var path = require('path')
|
||||
var Extension = require(path.join(__dirname, '..', '..', 'app', 'scripts', 'lib', 'extension-instance.js'))
|
||||
@ -11,7 +13,7 @@ describe('extension', function() {
|
||||
let extension
|
||||
|
||||
beforeEach(function() {
|
||||
window.chrome = {
|
||||
GLOBAL.chrome = {
|
||||
alarms: 'foo'
|
||||
}
|
||||
extension = new Extension()
|
||||
@ -24,13 +26,20 @@ describe('extension', function() {
|
||||
|
||||
describe('without chrome global', function() {
|
||||
let extension
|
||||
let realWindow
|
||||
|
||||
beforeEach(function() {
|
||||
window.chrome = undefined
|
||||
window.alarms = 'foo'
|
||||
realWindow = window
|
||||
window = GLOBAL
|
||||
GLOBAL.chrome = undefined
|
||||
GLOBAL.alarms = 'foo'
|
||||
extension = new Extension()
|
||||
})
|
||||
|
||||
after(function() {
|
||||
window = realWindow
|
||||
})
|
||||
|
||||
it('should use the global apis', function() {
|
||||
assert.equal(extension.alarms, 'foo')
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user