Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephanhoyer/spy-then
Simple async spy helper
https://github.com/stephanhoyer/spy-then
Last synced: about 2 months ago
JSON representation
Simple async spy helper
- Host: GitHub
- URL: https://github.com/stephanhoyer/spy-then
- Owner: StephanHoyer
- License: mit
- Created: 2016-05-29T19:39:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:49:52.000Z (about 1 year ago)
- Last Synced: 2024-04-13T22:24:43.203Z (9 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/StephanHoyer/spy-then.svg)](https://travis-ci.org/StephanHoyer/spy-then)
[![rethink.js](https://img.shields.io/badge/rethink-js-yellow.svg)](https://github.com/rethinkjs/manifest)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Dependency Status](https://david-dm.org/StephanHoyer/sock-channels.svg)](https://david-dm.org/StephanHoyer/sock-channels)# spy-then
Simple async spy helper## Usage
```javascript
var spyThen = require('spy-then')(optionalOptions)var makeSpy = spyThen(function() {
console.log('ready')
}, optionalOptions)spyA = makeSpy('foo')
spyB = makeSpy('bar')spyB('foo') // -> nothing happens
spyB('bar') // -> console.log('ready') will be called
```## Options
You can either initialize the library with options or you can give them to each
spy-maker individually.Possible options are
* `options.argCheck`: should be a function that gets two arguments, first one is
the expected argument, second one is the actual. You can feed those to your
assertions library
* `options.allowMultipleCalls`: should be true, if multiple calls of a spy are
allowed## Todo/Ideas
### Expect callCount
```javascript
spyA = makeSpy({
args: ['argOffirstCall', 'arfOfSecondCall'],
minCallCount: 2,
maxCallCount: 4
})
```## more options
* `minCallCount`
* `maxCallCount`