Pregunta

I'm mocking chrome.storage using jasmine's spyOn function like this:

this.fakeChromeStorage = {};
chrome = { storage: { sync: {get: function() {}, set: function() {}}}};
spyOn(chrome.storage.sync, 'get').and.callFake(function(key, callback) {
    callback();
});

But then when my application calls:

console.info(chrome.storage);
console.info(typeof chrome.storage);
console.info(chrome.storage.type);
console.info(typeof chrome.storage.type);

It prints:

[object Object]
object
undefined
undefined

How is this even possible?

¿Fue útil?

Solución

Yes, chrome.storage is an Object, chrome.storage.type is a property on the object chrome.storage which does not exists and therefor will be undefined.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top