Invoke callback instead of returning

This commit is contained in:
Kevin Sawicki 2016-06-28 13:02:03 -07:00
parent 2fe83bc5f0
commit d2d11ce8bd
2 changed files with 10 additions and 7 deletions

View file

@ -12,11 +12,17 @@ const setStorage = (storageType, storage) => {
window.localStorage.setItem(`__chrome.storage.${storageType}__`, json)
}
const scheduleCallback = (items, callback) => {
setTimeout(function () {
callback(items)
})
}
const getStorageManager = (storageType) => {
return {
get (keys, callback) {
const storage = getStorage(storageType)
if (keys == null) return storage
if (keys == null) return scheduleCallback(storage, callback)
let defaults = {}
switch (typeof keys) {
@ -30,7 +36,7 @@ const getStorageManager = (storageType) => {
}
break
}
if (keys.length === 0) return {}
if (keys.length === 0) return scheduleCallback({}, callback)
let items = {}
keys.forEach(function (key) {
@ -38,10 +44,7 @@ const getStorageManager = (storageType) => {
if (value == null) value = defaults[key]
items[key] = value
})
setTimeout(function () {
callback(items)
})
scheduleCallback(items, callback)
},
set (items, callback) {

View file

@ -1025,7 +1025,7 @@ describe('browser-window module', function () {
}, /Unexpected token }/)
})
describe.only('when the devtools is docked', function () {
describe('when the devtools is docked', function () {
it('creates the extension', function (done) {
w.webContents.openDevTools({mode: 'bottom'})