question(s): how to trigger client connection
bboydflo opened this issue · comments
Florin Cosmin commented
I am not sure exactly how to actually trigger a connection using sinon-chrome.
Here is my test:
const browser = require('sinon-chrome/webextensions');
const sinon = require('sinon');
it("multiple content scripts can connect to the same background script", () => {
let onConnect = sinon.spy();
browser.runtime.onConnect.addListener(onConnect);
browser.runtime.connect(null, { name: 'one' });
browser.runtime.connect(null, { name: 'two' });
browser.runtime.onConnect.trigger();
browser.runtime.onConnect.trigger();
assert(onConnect.callCount === 2, 'on connect has been called 2 times');
});
This seems to work but I am not sure why. I was expecting that I don't need to call browser.runtime.onConnect.trigger();
What is the best way to improve documentation? I have a hard time using sinon-chrome
as a new user.