acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
434 stars 46 forks source link

`chrome.alarms.getAll()` returns `undefined` instead of array of alarms #90

Closed ghost closed 5 years ago

ghost commented 5 years ago

chrome.alarms.getAll() should return an array of alarms. However, it is returning undefined using v3.0.1.

const chrome = require("sinon-chrome/extensions");

(async () => {
    let alarms = await chrome.alarms.getAll();
    console.log(alarms); // `undefined`

    await chrome.alarms.create("testAlarm", {
        delayInMinutes: 15
    });

    alarms = await chrome.alarms.getAll();
    console.log(alarms); // `undefined`

    let alarm = await chrome.alarms.get("testAlarm");
    console.log(alarm); // `undefined`
})();
ghost commented 5 years ago

Apologies. I did not realize these were API stubs, not for faking behavior.

JackZong commented 5 years ago

Apologies. I did not realize these were API stubs, not for faking behavior.

so, is that all of the returning should be mocked by self? And all of the returning should be mocked by .returns() ? is it right? thanks