nifty-wallet/test/unit/extension-test.js

78 lines
1.8 KiB
JavaScript
Raw Normal View History

var assert = require('assert')
var sinon = require('sinon')
const ethUtil = require('ethereumjs-util')
2016-07-25 17:33:22 -07:00
GLOBAL.chrome = {}
GLOBAL.browser = {}
var path = require('path')
var Extension = require(path.join(__dirname, '..', '..', 'app', 'scripts', 'lib', 'extension-instance.js'))
describe('extension', function() {
2016-08-29 17:34:12 -07:00
describe('extension.getURL', function() {
const desiredResult = 'http://the-desired-result.io'
describe('in Chrome or Firefox', function() {
GLOBAL.chrome.extension = {
getURL: () => desiredResult
}
it('returns the desired result', function() {
const extension = new Extension()
const result = extension.extension.getURL()
assert.equal(result, desiredResult)
})
})
describe('in Microsoft Edge', function() {
GLOBAL.browser.extension = {
getURL: () => desiredResult
}
it('returns the desired result', function() {
const extension = new Extension()
const result = extension.extension.getURL()
assert.equal(result, desiredResult)
})
})
})
describe('with chrome global', function() {
let extension
beforeEach(function() {
2016-07-25 17:33:22 -07:00
GLOBAL.chrome = {
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-25 17:33:22 -07:00
let realWindow
beforeEach(function() {
2016-07-25 17:33:22 -07:00
realWindow = window
window = GLOBAL
GLOBAL.chrome = undefined
GLOBAL.alarms = 'foo'
extension = new Extension()
})
2016-07-25 17:33:22 -07:00
after(function() {
window = realWindow
})
it('should use the global apis', function() {
assert.equal(extension.alarms, 'foo')
})
})
2016-08-29 17:34:12 -07:00
})