descartes
v0.0.9
Published
Mock async JavaScript libraries
Downloads
4
Readme
descartes
Mock async JavaScript libraries
Install
$ npm install --save descartes
Usage
import {Jar, withArgs, withExactArgs, onThis} from 'descartes';
it("should behave like this", async function(){
const jar = new Jar();
const stub = jar.probe('stub');
const spy = jar.sensor('spy');
//start async method
const result = myAsyncMethod(spy, stub);
await spy.called();
await spy.called(withArgs('something'));
await spy.called(withExactArgs('something', 'else'));
stub.resolvesTo('something');
await stub.called();
stub.rejects(new Error('it should handle this'));
await stub.called(
withArgs(13),
onThis(window));
const call = await spy.called();
call.args[0].should.equal('something');
call.args[1].should.be.a('Function');
call.args[1](null, 'result');
(await result).should.equal('expected value');
});
License
MIT © Marius Gundersen