Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created July 12, 2017 01:54
Show Gist options
  • Save khaosdoctor/b697888e2dbad1948cecc717ed18cfb4 to your computer and use it in GitHub Desktop.
Save khaosdoctor/b697888e2dbad1948cecc717ed18cfb4 to your computer and use it in GitHub Desktop.
Stub example
describe('Exemplo de stub com Sinon', (assert) => {
var message = 'an example message';
var stub = sinon.stub().throws();
var spy1 = sinon.spy();
var spy2 = sinon.spy();
PubSub.subscribe(message, stub);
PubSub.subscribe(message, spy1);
PubSub.subscribe(message, spy2);
PubSub.publishSync(message, undefined);
assert(spy1.called);
assert(spy2.called);
assert(stub.calledBefore(spy1));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment