Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question(s): how to trigger client connection #79

Open
bboydflo opened this issue Jun 18, 2018 · 0 comments
Open

question(s): how to trigger client connection #79

bboydflo opened this issue Jun 18, 2018 · 0 comments

Comments

@bboydflo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant