1.1.1 • Published 9 months ago

hein-plugin-sinon v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

hein-plugin-sinon

npm npm npm npm

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);
1.1.1

9 months ago

1.1.0

9 months ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago