0.0.9 • Published 8 years ago

descartes v0.0.9

Weekly downloads
4
License
MIT
Repository
github
Last release
8 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

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

9 years ago

0.0.0

9 years ago