hein-plugin-sinon
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i hein-plugin-sinon

Weekly Downloads

80

Version

1.1.1

License

MIT

Unpacked Size

90.9 kB

Total Files

44

Last publish

Collaborators

  • ktammekivi