0.0.9 • Published 10 years ago

descartes v0.0.9

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

descartes NPM version Build Status Dependency Status Coverage percentage

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

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago