{"_id":"fzkes","_rev":"26-9b7ec5310069d4adcff0ea41af511821","name":"fzkes","description":"A faking library","dist-tags":{"latest":"0.15.0"},"versions":{"0.7.1":{"name":"fzkes","version":"0.7.1","description":"A faking library","main":"index.js","scripts":{"test":"mocha","install":"node install.js"},"dependencies":{"browserify":"~2.13.3"},"devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","glob":"~3.2.1"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","_id":"fzkes@0.7.1","dist":{"shasum":"d643ca1c6886b0a44095404bb83ffe066154a82c","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.7.1.tgz","integrity":"sha512-goM6BpXLFx9wDZU5YS8BlF+qrMupeVI19uCi851WW0aAyyQZ+6LyEU1MpST1JcaBJVUsejBv7qhoZ4d4jpPdOA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaC8eJRph/B/7z/qsyw8qdWXNDf6A90Y7moEn+Wv8s3QIgVg0Hz1gG1Q7PB8xiMy5cuPtgzc4n/zxR/BHh58tVcIU="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.8.0":{"name":"fzkes","version":"0.8.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha","install":"node install.js"},"dependencies":{"browserify":"~2.13.3"},"devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","glob":"~3.2.1","karma":"~0.8.5"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","_id":"fzkes@0.8.0","dist":{"shasum":"5802e60195a6aa7e601c8dd73d5387ffbfc25916","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.8.0.tgz","integrity":"sha512-r3HNhb9moqrlmuxMbjnwtytHAdjjeP/E/7W5m0Jd9qWn+2BX1JXijLy5KyqKwC4K5SVuKxy+fKTkBw1yAPDpAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUlK9eK/cjP6leCO+zXBZA6zWoXFS9Tl/Ya432XRg7nwIhAOdc00EfUqAHcFjM/e6gs1Y6vdSFyrV4tiIOn1QfdQy1"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.9.0":{"name":"fzkes","version":"0.9.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha","install":"node install.js"},"dependencies":{"browserify":"~2.13.3"},"devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","glob":"~3.2.1","karma":"~0.8.5"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"_id":"fzkes@0.9.0","dist":{"shasum":"04f7bf4d2ee55ce29e26d49d1d5f1f9463b0bc28","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.9.0.tgz","integrity":"sha512-aRn5pBb+6PyZRuh4vivK+UjoCZ17YpC1h3B5mws4DAesCnEQlifV2UWZxnHTkY0FWfp0gVkmciVQCITEAreu8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDxBjI36asK70VtlI7y48+yyruV5/D0kMsu15z+SqOd+AiAjHvNeznaHsrklj43dVEa5m2Ijze8eWGaXip/SKRblLA=="}]},"_from":".","_npmVersion":"1.2.23","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.10.0":{"name":"fzkes","version":"0.10.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"_id":"fzkes@0.10.0","dist":{"shasum":"32b952b1d84a3871ef9e61982c3534d5b1717fde","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.10.0.tgz","integrity":"sha512-v71q/t4wpzmlPD5F+9heBFEccdqKBxefSoC0hgqlPAm6U/s97G6l8UNeB+MknkRvHYYFq85Yf0a4iFvJRCesow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDV2g0qRcVJnsLkbbDa+BbtGXVwIHZgvJGB0hWvwizqewIhAJ9zh6Fk0DUy/wyavRvEskeHWGty5xR7GoE/nbgEqDoN"}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.10.1":{"name":"fzkes","version":"0.10.1","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"_id":"fzkes@0.10.1","dist":{"shasum":"55a460896f03616ecd051b08e368e8f5d58db5fd","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.10.1.tgz","integrity":"sha512-asxdiQbmaIQ4gTdTHxLR8h7oe6ewoyizXivkm5uutER7CVAINmYsLdo4TFB8Tp5pZ9KMIh2vjAzDTW8IoWSp3A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDMuLz9H/NzlxvWy8DYc+EjBozqgAA3xmYXHNEBWY1JzAiAZLfnZ0i05h6YeWYLbyeUNGrFJaAh2+Qt4CESnnSIgbg=="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.11.0":{"name":"fzkes","version":"0.11.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"_id":"fzkes@0.11.0","dist":{"shasum":"3dcb6053cbc6da1d267adf88577d8d31d9ba6f03","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.11.0.tgz","integrity":"sha512-/VWADRwQxwVe5SGuvhXekHhTJFf/v5d6ghrbSy2oFhAE0H+aa/TO4da8uxs7yTv62F9DrR9u394ot5AVq/Pl0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDkKgDrt2l5FDQPST2YmrADp1gVh1tG02Jf9fe5hmyMvQIgfKY/2a6eUMgc42Mfp6fjhD9hzAzisVCOHBXoh/o4RhI="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.11.1":{"name":"fzkes","version":"0.11.1","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"_id":"fzkes@0.11.1","dist":{"shasum":"24b1be3d93ce21db033286cc1d4f767b3af397cd","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.11.1.tgz","integrity":"sha512-FJZ+c2Kq5P4aVCdG5LCR4eWfHH/GPsy0F+XYSEU4qnD8XVjGmVbvuvezBLYxrlQSABfa8asm1Bz5q6a0+frwSw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/3fQwVkmWf4RhuDX13Y5HrAQRQAVVo9M7kjPh3sxbDgIgQ4TLGB1eVuQRySjLvnf7gLkApe5Pife5n4425YXzKtw="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.12.0":{"name":"fzkes","version":"0.12.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"homepage":"https://github.com/fizker/js-fzkes","_id":"fzkes@0.12.0","dist":{"shasum":"71680f709484b09ef5ac170518e617d2627ebfe7","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.12.0.tgz","integrity":"sha512-XQWdlBiO3htmtsykHw1EpzLzRAKa40io5/ZWqwO7JK9RqYGoRf5nw8L8hrbsYOoJSE2SURiMF4CHKo4n58Y2ag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZAr9fvFCLddNxHhYPRTKsyVnxzpuJZZppZxY3+L8oOAIgQhNB2tstdIsseL00yMQXy4Rx9K9O7TdJrU+XRr18zmo="}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"directories":{}},"0.13.0":{"name":"fzkes","version":"0.13.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"homepage":"https://github.com/fizker/js-fzkes","_id":"fzkes@0.13.0","dist":{"shasum":"6d78b2a12ad830fdb47649d3ff4d7f6f5077448d","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.13.0.tgz","integrity":"sha512-vtcUa96DdjC2MJSeLk1GUIDx9sZ3ugo+usIYPrCeFsyblqgKDD6CMIaAXyW2Bed5+AySET1VqSyt2aUIyrLh7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0syXGm1enzwbmP/iw3lT1Z/AH0toktbDcrhYbCQ44LAIgMzKlBloitsymi3Yhw6tCBTVsCz145vdsP55qfM4JQ6M="}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}]},"0.14.0":{"name":"fzkes","version":"0.14.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run","install":"node install.js"},"dependencies":{"browserify":"~2.28.0"},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"homepage":"https://github.com/fizker/js-fzkes","_id":"fzkes@0.14.0","dist":{"shasum":"263026afd3e00ae3a0bf499e2633a928b116d964","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.14.0.tgz","integrity":"sha512-OMbMCj/Fuc+3kVFu3Ao5il7+UtByQ+QnQlr+Pyq8wZSJsa2MPfHTKh/5zGFnMN4KpB2WG2XbmJN1R25XViOtTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIwf2wRBqL2AA6lND7tkhk7iA3IMnX9uR6xbCqe08nswIhANx3XHgoLwFPuiKfRSbmODiTUg7KSKnfSaQQ3cvtJKT4"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}]},"0.14.1":{"name":"fzkes","version":"0.14.1","description":"A faking library","main":"index.js","scripts":{"test":"mocha && karma start --browsers Chrome,Firefox --single-run"},"dependencies":{},"devDependencies":{"chai":"~1.7","mocha":"~1.12","glob":"~3.2.6","karma":"~0.8.8"},"repository":{"type":"git","url":"git://github.com/fizker/js-fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","gitHead":"ecb934f3db86726eccf17de20e606b6c0be032c8","bugs":{"url":"https://github.com/fizker/js-fzkes/issues"},"homepage":"https://github.com/fizker/js-fzkes","_id":"fzkes@0.14.1","_shasum":"1ae69bf83ea0ad58791db5380e2b34db1fd07df7","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"fizker","email":"benjamin@fizkerinc.dk"},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"dist":{"shasum":"1ae69bf83ea0ad58791db5380e2b34db1fd07df7","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.14.1.tgz","integrity":"sha512-7UKwm9gCHBGgqWnuFBybb/Hbrnj9IPxIbQD19QKlo78YWeE5fWsiJbJ5QrzM+vS1rTtYpwL6XzAPUc49rr2dAQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCPGCmnei/rDmmlghvBXeZXJjP44Rz0LPJDm7fBIyG9cgIgXW35KERBw/JVIRd2XNURUSfSdkNVbIkuVHmktBqsA2M="}]}},"0.15.0":{"name":"fzkes","version":"0.15.0","description":"A faking library","main":"index.js","scripts":{"test":"mocha"},"dependencies":{"decircularize":"^1.0.0"},"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0"},"repository":{"type":"git","url":"git://github.com/fizker/fzkes.git"},"keywords":["javascript","js","fake","faking","mocha","chai","test"],"author":{"name":"Benjamin Horsleben"},"license":"WTFPL","gitHead":"29f8328ef99e74c17d3186bcb4f07a240f8d4077","bugs":{"url":"https://github.com/fizker/fzkes/issues"},"homepage":"https://github.com/fizker/fzkes#readme","_id":"fzkes@0.15.0","_shasum":"1b91fb3118b9ffcc728d542c316f4fb0b22d6bd8","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.4","_npmUser":{"name":"fizker","email":"npm@fizkerinc.dk"},"dist":{"shasum":"1b91fb3118b9ffcc728d542c316f4fb0b22d6bd8","tarball":"https://registry.npmjs.org/fzkes/-/fzkes-0.15.0.tgz","integrity":"sha512-Lmhw3eT//4Eh75UHLPtlsCZombFmoM7BfLxbuOH8Z6PBXYlV3gV8HjmtrLuv290sV6KDnM/d0dor1u4mzgDsAA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGBrILM7ul0+FGAjggnuV4iFpgr1ktj8x4PcJie8InnaAiEA86sMsHFHzvLh198wWonnVeewXBJHknIoxMIEEhBWQTw="}]},"maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/fzkes-0.15.0.tgz_1491168820231_0.5793487215414643"}}},"readme":"fzkes\n=====\n\nA faking library\n\nI must immediately apologize for the name; it is a horrible pun combining `fzk`\n(a shortening of the name of my company) and `fakes`. But it does have a nice ring to it,\nand I want it to be short and unique. So there it is.\n\n\nHow to use\n----------\n\n### Creating fakes\n\n\tvar fzkes = require('fzkes')\n\n\t// Creating a stand-alone fake, great for use as a callback\n\tvar fake = fzkes.fake()\n\n\t// For overriding an original function, great for restoring later\n\tvar fs = require('fs')\n\tfzkes.fake(fs, 'readFile')\n\n\t// For faking all functions on an object\n\tfzkes.fakeAll(fs)\n\n\n#### fakeAll\n\nThe `fzkes.fakeAll()` function can take an options-dictionary, allowing for\noverriding the default action. The options are:\n\n- `callsOriginal`: The default. `fake.callsOriginal()` is evoked on all fakes.\n- `none`: No action is taken on the fakes.\n- `throws`: A `'Fake not overridden'` exception will be evoked on all fakes.\n\nAll fakes can of course be overridden later on, the default is just what should\nhappen out-of-the-box.\n\n\n### Resetting fakes\n\nResetting a fake (`fake.reset()`) will set its internal state to what it was\nwhen it was new.\n\nIt is possible to reset all fakes by calling `fzkes.reset()` or `scope.reset()`.\n\n\n### Restoring original functions\n\nThere are three ways to easily doing this, depending on the scope:\n\n1. Restoring a single fake: `fake.restore()`\n2. Restoring all fakes across the board: `fzkes.restore()`\n\nThe last is a bit more tricky; A sub-scope can be creating by calling\n`fzkes.scope()`. The scope have all methods (except `chai`) that the original\n`fzkes` object have, except the `restore()` function on a scope only affects\nfakes created within that scope.\n\n\n### Injecting data\n\n\tfake.returns('abc')\n\tfake.throws(new Error('some error'))\n\tfake.calls(function() { console.log('was called') })\n\n\t// If it replaced a function on an object:\n\tfake.callsOriginal()\n\n\t// Conditional injects\n\tfake.withArgs(1,2).returns(3)\n\tfake.withArgs(1,2).callsOriginal()\n\nEach action (`returns`, `throws`, `calls`, etc) returns the fake, to make it\neasier to assign to return values and the like:\n\n\tfake.returns({\n\t\ta: fzkes.fake('a').returns(3),\n\t\tb: fzkes.fake('b').throws()\n\t})\n\nIt can also chain the withArgs() automatically:\n\n\tvar fake = fzkes.fake('name')\n\t\t.returns(1)\n\t\t.withArgs(1,2).returns(3)\n\t\t.withArgs(1,3).returns(4)\n\t\t.withArgs(1,4).throws(new Error('some error'))\n\tfake(1,1) // => 1\n\tfake(1,2) // => 3\n\tfake(1,3) // => 4\n\tfake(1,4) // => throws\n\n\n#### Advanced `withArgs`\n\nThere is a more advanced form of `withArgs` called `withComplexArgs`.\nIt allows for skipping arguments entirely, as well as defining regular\nexpressions to validate against strings.\n\n\tvar fake = fzkes.fake('name')\n\t\t.returns(1)\n\t\t.withComplexArgs(null, { value: 2 }).returns(2)\n\t\t.withComplexArgs({ regex: /ab?c/ }).returns(3)\n\n\tfake(1, 1) // => 1\n\tfake(1, 2) // => 2\n\tfake('a', 2) // => 2\n\tfake('abc') // => 3\n\tfake('ac') // => 3\n\n\n### Calling callbacks\n\nThere is a built-in helper for calling callbacks: `callsArg`. If the callback\nthrows an exception, the fake with throw it as well.\n\nIt can take the following options:\n\n- `notify`: A function to notify whenever the fake is called. It is called as\n\t`function(error, returnValue)`, where `error` is whatever the callback\n\tthrew, and `returnValue` is what the callback returned. If `async` is\n\tfalse, the fake will return whatever the `notify` function returns.\n\n\tThis option is also perfect for [mocha][mocha] style async handlers.\n\n- `returns`: A value to return whenever the fake is called. This takes\n\tpresedence over the return-value of `notify`, but exceptions still triumph.\n\n- `now`: A flag that determines if the action should occur for future calls or\n\tfor the first unhandled call. This will throw if the fake have no unhandled\n\tcalls.\n\n- `async`: A flag determining if the callback should be called immediately or in\n\tthe next tick (which would simulate an async call).\n\n- `arg`: The argument to call. This can be the parameter index (0-n), `'first'`\n\tor `'last'`. It defaults to `'last'`.\n\n- `arguments`: An array of the arguments to pass to the callback.\n\n\nExamples follow:\n\n\t// Default is calling the last function found, node-style\n\tfake.callsArg()\n\n\t// It can be controlled\n\tfake.callsArg({ arg: 'first' })\n\t// 0-indexed argument list\n\tfake.callsArg({ arg: 1 })\n\n\t// It defaults to calling the callback immediately, but this can be changed\n\tfake.callsArg({ async: true })\n\n\t// Default is no parameters to the callback, but these can be controlled\n\tfake.callsArg({ arguments: [ 1, 2 ] })\n\n[mocha]: http://mochajs.org/\n\n### Emulating calls after they have been called\n\nSometimes, it is not feasible to prepare the fake properly; in these cases,\nemulating the call after the fact makes the code much better.\n\n`fzkes` supports this as an option for the `fake.calls()`, `fake.callsArg()` and\n`fake.callsOriginal()` functions.\n\nThe code would look as the following:\n\n\tfake(1,2,3)\n\n\tfake.calls(fn, { now: true })\n\tfake.callsOriginal({ now: true })\n\tfake.callsArg({ now: true })\n\nIt works with all other options on the `fake.callsArg()` call.\n\nIt forwards the next unhandled call as it appeared on the `fake`, and throws an\nexception if there are no unhandled calls:\n\n\tfake(1,2,3)\n\t// Goes through\n\tfake.callsOriginal({ now: true })\n\n\ttry {\n\t\tfake.calls(fn, { now: true })\n\t} catch(e) {\n\t\t// e.message would say that fake had no unhandled calls.\n\t}\n\nIf any of the functions was set up in advance, calls are not considered\nunhandled, and any call with `{ now: true }` will throw an exception.\nTo begin building unhandled calls, make a `fake.calls(null)` invocation.\n\n\tfake.callsOriginal()\n\t// this call is handled immediately\n\tfake()\n\texpect(function() {\n\t\tfake.callsOriginal({ now: true })\n\t}).to.throw()\n\n\t// resetting the expectations\n\tfake.calls(null)\n\n\t// it now works again\n\tfake()\n\tfake.callsOriginal({ now: true })\n\n\n### Asserting\n\n\tfake.wasCalled()\n\tfake.wasCalledWith(1, 2, 3)\n\tfake.wasCalledWithExactly(1, 2, 3)\n\tfake.callCount == 2\n\n\n### Using with [chai](http://chaijs.com)\n\n\tchai.use(fzkes)\n\tfake.should.have.been.called // at least once\n\tfake.should.have.been.called(2) // precisely 2 times\n\tfake.should.have.been.calledWith(1,2,3)\n\n\n### Running in the browser\n\nUse a tool like browserify or webpack to generate a browser-compatible version\nof the tests. Then simply follow the guide above for setting it up and\ninteracting with it.\n\n__NOTE:__ Pre v0.15, the package built a browser-version always. This task have\nnow been delegated to the consumer of the library.\n","maintainers":[{"name":"fizker","email":"benjamin@fizkerinc.dk"}],"time":{"modified":"2022-06-18T04:36:29.007Z","created":"2013-05-14T06:52:55.170Z","0.7.1":"2013-05-14T06:52:58.041Z","0.8.0":"2013-05-22T22:02:14.020Z","0.9.0":"2013-06-11T21:52:08.142Z","0.10.0":"2013-08-20T21:18:09.327Z","0.10.1":"2013-09-10T22:03:58.974Z","0.11.0":"2013-10-15T18:21:36.561Z","0.11.1":"2013-10-18T08:36:09.471Z","0.12.0":"2014-01-08T20:44:04.876Z","0.13.0":"2014-01-25T22:55:04.933Z","0.14.0":"2014-04-03T09:43:16.078Z","0.14.1":"2014-10-29T11:17:37.657Z","0.15.0":"2017-04-02T21:33:40.966Z"},"author":{"name":"Benjamin Horsleben"},"repository":{"type":"git","url":"git://github.com/fizker/fzkes.git"},"readmeFilename":"readme.md","homepage":"https://github.com/fizker/fzkes#readme","keywords":["javascript","js","fake","faking","mocha","chai","test"],"bugs":{"url":"https://github.com/fizker/fzkes/issues"},"license":"WTFPL"}