{"_id":"will-call","_rev":"300138","name":"will-call","description":"check that expected function calls are actually made","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"cjihrig","email":""}],"time":{"modified":"2021-06-03T19:04:50.000Z","created":"2016-03-28T19:58:32.897Z","1.0.1":"2017-11-09T15:16:25.678Z","1.0.0":"2016-03-28T19:58:32.897Z"},"users":{},"author":{"name":"Continuation Labs","email":"contact@continuation.io","url":"http://continuation.io/"},"repository":{"type":"git","url":"git+https://github.com/continuationlabs/will-call.git"},"versions":{"1.0.1":{"name":"will-call","version":"1.0.1","description":"check that expected function calls are actually made","author":{"name":"Continuation Labs","email":"contact@continuation.io","url":"http://continuation.io/"},"main":"lib/index.js","homepage":"https://github.com/continuationlabs/will-call","repository":{"type":"git","url":"git+https://github.com/continuationlabs/will-call.git"},"bugs":{"url":"https://github.com/continuationlabs/will-call/issues"},"license":"MIT","scripts":{"lint":"belly-button -f","test":"npm run lint && lab -v -a code -c -m 10000"},"devDependencies":{"belly-button":"4.x.x","code":"5.x.x","lab":"15.x.x"},"keywords":["call","must call","will call","should call","assert","expect"],"gitHead":"38453cc65023d10dd424f7bdbd7e3f99e0d114cf","_id":"will-call@1.0.1","_npmVersion":"5.4.2","_nodeVersion":"8.8.1","_npmUser":{"name":"cjihrig","email":"cjihrig@gmail.com"},"dist":{"shasum":"9b37561ea7156aaba21b28fdf635b80fe78bf166","size":2628,"noattachment":false,"key":"/will-call/-/will-call-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/will-call/download/will-call-1.0.1.tgz"},"maintainers":[{"name":"cjihrig","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/will-call-1.0.1.tgz_1510240584726_0.49613498733378947"},"directories":{},"publish_time":1510240585678,"_hasShrinkwrap":false,"_cnpm_publish_time":1510240585678},"1.0.0":{"name":"will-call","version":"1.0.0","description":"check that expected function calls are actually made","author":{"name":"Continuation Labs","email":"contact@continuation.io","url":"http://continuation.io/"},"main":"lib/index.js","homepage":"https://github.com/continuationlabs/will-call","repository":{"type":"git","url":"git+https://github.com/continuationlabs/will-call.git"},"bugs":{"url":"https://github.com/continuationlabs/will-call/issues"},"license":"MIT","scripts":{"lint":"belly-button -f","test":"npm run lint && lab -v -a code -c"},"devDependencies":{"belly-button":"2.0.1","code":"2.1.1","lab":"10.3.0"},"keywords":["call","must call","will call","should call","assert","expect"],"gitHead":"ebb617798302ddf4d150f3d4fbbeb31d2fe3eccb","_id":"will-call@1.0.0","_shasum":"398cff00082e051c2da01cc9f52937ad935524a4","_from":".","_npmVersion":"3.8.3","_nodeVersion":"5.7.0","_npmUser":{"name":"cjihrig","email":"cjihrig@gmail.com"},"dist":{"shasum":"398cff00082e051c2da01cc9f52937ad935524a4","size":3739,"noattachment":false,"key":"/will-call/-/will-call-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/will-call/download/will-call-1.0.0.tgz"},"maintainers":[{"name":"cjihrig","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/will-call-1.0.0.tgz_1459195111899_0.05263947602361441"},"directories":{},"publish_time":1459195112897,"_cnpm_publish_time":1459195112897,"_hasShrinkwrap":false}},"readme":"# will-call\n\n[![Current Version](https://img.shields.io/npm/v/will-call.svg)](https://www.npmjs.org/package/will-call)\n[![Build Status via Travis CI](https://travis-ci.org/continuationlabs/will-call.svg?branch=master)](https://travis-ci.org/continuationlabs/will-call)\n![Dependencies](http://img.shields.io/david/continuationlabs/will-call.svg)\n\n[![belly-button-style](https://cdn.rawgit.com/continuationlabs/belly-button/master/badge.svg)](https://github.com/continuationlabs/belly-button)\n\n**Credit:** This module borrows heavily from the `common.mustCall()` functionality in Node core's test suite.\n\n`will-call` allows you to mark functions that should be executed. You can later check which functions were actually called.\n\n```javascript\nconst WillCall = require('will-call');\nconst wc = new WillCall();\nconst foo = wc.expect(function foo () { return 'foo'; });     // must be called once\nconst bar = wc.expect(function bar () { return 'bar'; }, 2);  // must be called twice\nconst baz = wc.expect(function baz () { return 'baz'; });     // must be called once\n\nfoo();\nbar();\nbaz();\nbaz();\n\nconst results = wc.check();\n// results contains an array of length two, corresponding to bar() and baz()\n// Each entry provides the function name, a stack, expected calls, and actual calls\n```\n\n## Methods\n\n`will-call` exports a constructor function that takes no arguments. Constructed instances support the following methods.\n\n### `WillCall.prototype.expect(fn [, expected])`\n\n  - Arguments\n    - `fn` (function) - The function that is expected to be called.\n    - `expected` (integer) - The exact number of times that `fn` should be called. If a non-negative integer is not received, this defaults to 1. Optional.\n  - Returns\n    - A wrapped version of `fn`. The wrapped function should behave the same as `fn`.\n\nThis function specifies the exact number of times that a given function is expected to be called. `expect()` returns a wrapped version of the `fn` argument. It is important that the wrapped function be used instead of the original `fn` function.\n\n### `WillCall.prototype.check()`\n\n  - Arguments\n    - None\n  - Returns\n    - Array of objects. Each object adheres to the following schema.\n      - `name` (string) - The name of the function, or `'<anonymous>'` if the function doesn't have a name.\n      - `expected` (integer) - The number of times the function was expected to be called.\n      - `actual` (integer) - The number of times the function was actually called.\n      - `stack` (string) - A partial stack trace identifying where the function was passed to `expect()`.\n\nThis function verifies that all expected functions were called the correct number of times. `check()` returns an array identifying the functions that were **not** called correctly. This function does not alter any internal state, and can be called multiple times.\n","_attachments":{},"homepage":"https://github.com/continuationlabs/will-call","bugs":{"url":"https://github.com/continuationlabs/will-call/issues"},"license":"MIT"}