acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
439 stars 48 forks source link

Withargs not working for oncommand listerners #99

Open thamaraiselvam opened 4 years ago

thamaraiselvam commented 4 years ago

background.js

chrome.commands.onCommand.addListener(function(command) {
console.log(command)// print "current-tab-1"
});

test.js

chrome.commands.onCommand.trigger('current-tab-1') //triggers function and can see print message
assert.ok(chrome.commands.onCommand.addListener.calledOnce); // works fine
assert.ok(chrome.commands.onCommand.addListener.withArgs('current-tab-1').calledOnce); //fails

following code support to return true

assert.ok(chrome.commands.onCommand.addListener.withArgs('current-tab-1').calledOnce);