hein-plugin-sinon
v1.1.1
Published
hein plugin for sinon assertions
Downloads
412
Readme
hein-plugin-sinon
Plugin for hein that adds assertions for sinon.
Installation
import { use } from 'hein';
import { sinonPlugin } from 'hein-plugin-sinon';
use(sinonPlugin);
Usage
called
Asserts that spy has been called at least once
const s = sinon.spy();
s();
expect(s).to.have.been.called();
calledOnce
Asserts that spy has been called exactly once
const s = sinon.spy();
s();
expect(s).to.have.been.calledOnce();
calledTwice
Asserts that spy has been called exactly twice
const s = sinon.spy();
s(); s();
expect(s).to.have.been.calledTwice();
calledThrice
Asserts that spy has been called exactly three times
const s = sinon.spy();
s(); s(); s();
expect(s).to.have.been.calledThrice();
calledTimes
Asserts that spy has been called exactly n times
const s = sinon.spy();
s(); s(); s();
expect(s).to.have.been.calledTimes(3);
calledWith
Asserts that spy has been called with the given arguments
const s = sinon.spy();
s('a', 'b', 'c');
expect(s).to.have.been.calledWith('a', 'b', 'c');
calledWithMatch
Asserts that spy has been called with partial arguments
const s = sinon.spy();
s({ a: 1, b: 2, c: 3});
expect(s).to.have.been.calledWithMatch({
a: 1,
b: sinon.match.number
});
calledBefore
Asserts that spy has been called before the given spy
const s = sinon.spy();
const s2 = sinon.spy();
s();
s2();
expect(s).to.have.been.calledBefore(s2);
calledAfter
Asserts that spy has been called after the given spy
const s = sinon.spy();
const s2 = sinon.spy();
s2();
s();
expect(s).to.have.been.calledAfter(s2);