1.2.2 • Published 8 years ago

seneca-stub v1.2.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

seneca-stub

A utility for stubbing seneca.js patterns using Sinon.JS

This is based on Denis Luchkin-Zhou's stub utility from seneca-as-promised

Install

npm install seneca-stub

Getting Started

const Seneca = require('seneca')();
require('seneca-stub')(Seneca);

Return static data

const stub = Seneca.stub('role:test,cmd:stub', { foo: 'bar' });
await Seneca.act('role:test,cmd:stub', { herp: 'derp' }); // { foo: 'bar' }

stub.data(); // { role: 'test', cmd: 'stub', herp: 'derp' }

Use custom function

const stub = Seneca.stub('role:test,cmd:stub', function(args, done) {
	var result = {greeting: 'hello '+ args.name }
	done(null, result)
});
await Seneca.act('role:test,cmd:stub', { name: 'john' }); // { greeting: 'hello john' }

stub.data(); // { role: 'test', cmd: 'stub', name: 'john' }

If value provided to Seneca.stub is an Error, then it will be thrown instead of being returned.

1.2.2

8 years ago

1.1.2

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago