@supertape/operator-stub
supertape stub operator
Last updated a year ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @supertape/operator-stub 
SYNC missed versions from official npm registry.

@supertape/operator-stub NPM version Build Status Coverage Status

supertape operator simplifies work with @cloudcmd/stub.

Install

npm i @supertape/operator-stub -D

Operators

Adds next operators to work with:

t.calledWith(fn, args [, message])

import test, {stub} from 'supertape';

test('function call', (t) => {
    const fn = stub();
    
    fn('hello', 'world');
    
    t.calledWith(fn, ['hello', 'world'], 'fn should be called with "hello", "world"');
    t.end();
});

t.calledWithNoArgs(fn[, message])

import test, {stub} from 'supertape';

test('function called with no args', (t) => {
    const fn = stub();
    
    fn();
    
    t.calledWithNoArgs(fn);
    t.end();
});

t.calledCount(fn, count[, message])

import test, {stub} from 'supertape';

test('function called count', (t) => {
    const fn = stub();
    
    fn();
    fn();
    
    t.calledCount(fn, 2);
    t.end();
});

t.calledOnce(fn [, message])

import test, {stub} from 'supertape';

test('function called once', (t) => {
    const fn = stub();
    
    fn('hello');
    
    t.calledOnce(fn);
    t.end();
});

t.calledTwice(fn, count[, message])

import test, {stub} from 'supertape';

test('function called twice', (t) => {
    const fn = stub();
    
    fn('hello');
    fn('world');
    
    t.calledTwice(fn);
    t.end();
});

t.calledWithNew(fn, count[, message])

import test, {stub} from 'supertape';

test('function called with new', (t) => {
    const fn = stub();
    
    new fn();
    
    t.calledWithNew(fn);
    t.end();
});

t.calledBefore(fn1, fn2[, message])

Check that fn1 called before fn2. Do not forget to set names of stubs.

import test, {stub} from 'supertape';

test('function called with new', (t) => {
    const init = stub().withName('init');
    const show = stub().withName('show');
    
    init();
    show();
    
    t.calledBefore(show, init);
    t.end();
});

t.calledAfter(fn1, fn2[, message])

Check that fn1 called after fn2. Do not forget to set names of stubs.

import test, {stub} from 'supertape';

test('function called with new', (t) => {
    const init = stub().withName('init');
    const show = stub().withName('show');
    
    init();
    show();
    
    t.calledAfter(init, show);
    t.end();
});

t.calledInOrder([fn1, fn2, fnN][, message])

Check that array of stubs fns called in order; Do not forget to set names of stubs.

import test, {stub} from 'supertape';

test('function called with new', (t) => {
    const init = stub().withName('init');
    const show = stub().withName('show');
    
    init();
    show();
    
    t.calledInOrder([init, show]);
    t.end();
});

License

MIT

Current Tags

  • 3.1.0                                ...           latest (a year ago)

20 Versions

  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.10.0                                ...           3 years ago
  • 1.9.0                                ...           3 years ago
  • 1.8.0                                ...           3 years ago
  • 1.7.1                                ...           3 years ago
  • 1.7.0                                ...           3 years ago
  • 1.6.0                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.2                                ...           3 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (12)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE