2016-07-21 19:45:32 +02:00
|
|
|
var assert = require('assert')
|
|
|
|
var sinon = require('sinon')
|
|
|
|
const ethUtil = require('ethereumjs-util')
|
2016-07-26 02:33:22 +02:00
|
|
|
GLOBAL.chrome = {}
|
|
|
|
GLOBAL.browser = {}
|
2016-07-21 19:45:32 +02:00
|
|
|
|
|
|
|
var path = require('path')
|
|
|
|
var Extension = require(path.join(__dirname, '..', '..', 'app', 'scripts', 'lib', 'extension-instance.js'))
|
|
|
|
|
|
|
|
describe('extension', function() {
|
|
|
|
|
|
|
|
describe('with chrome global', function() {
|
|
|
|
let extension
|
|
|
|
|
|
|
|
beforeEach(function() {
|
2016-07-26 02:33:22 +02:00
|
|
|
GLOBAL.chrome = {
|
2016-07-21 19:45:32 +02:00
|
|
|
alarms: 'foo'
|
|
|
|
}
|
|
|
|
extension = new Extension()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should use the chrome global apis', function() {
|
|
|
|
assert.equal(extension.alarms, 'foo')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('without chrome global', function() {
|
|
|
|
let extension
|
2016-07-26 02:33:22 +02:00
|
|
|
let realWindow
|
2016-07-21 19:45:32 +02:00
|
|
|
|
|
|
|
beforeEach(function() {
|
2016-07-26 02:33:22 +02:00
|
|
|
realWindow = window
|
|
|
|
window = GLOBAL
|
|
|
|
GLOBAL.chrome = undefined
|
|
|
|
GLOBAL.alarms = 'foo'
|
2016-07-21 19:45:32 +02:00
|
|
|
extension = new Extension()
|
|
|
|
})
|
|
|
|
|
2016-07-26 02:33:22 +02:00
|
|
|
after(function() {
|
|
|
|
window = realWindow
|
|
|
|
})
|
|
|
|
|
2016-07-21 19:45:32 +02:00
|
|
|
it('should use the global apis', function() {
|
|
|
|
assert.equal(extension.alarms, 'foo')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|