{"name":"@supertape/operator-stub","version":"4.0.0","keywords":["operator","stub","function","tap","tape","testing"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@supertape/operator-stub@4.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"http://github.com/coderaiser/supertape","bugs":{"url":"https://github.com/coderaiser/supertape/issues"},"tag":false,"dist":{"shasum":"79a8893607af65d065bbf51e778de74339380052","tarball":"http://registry-npm.ywwl.com/@supertape/operator-stub/download/@supertape/operator-stub-4.0.0.tgz","fileCount":5,"integrity":"sha512-t+LAKOA92m1pidzaXYzRHMAffYqqk19QOkMEbarP57/Sav90x9Q3ndvH6kRwa3HQhU2N7SuZrc21zh7vSwIOKA==","signatures":[{"sig":"MEUCIQDY5JWecXWEUuscWRR59SEmb6hJTqlqs8IrSvQv6c65FQIgQ11/pty8yT97OVuJ5liWzi2RnRmLPIYjW9H3eQBbz1E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12278,"size":3280,"noattachment":false,"key":"/@supertape/operator-stub/-/@supertape/operator-stub-4.0.0.tgz"},"main":"./lib/stub.js","type":"module","types":"./lib/stub.d.ts","engines":{"node":">=22"},"gitHead":"d40865d35fc86d15bd6a4a8be965b1bbfd5e1c90","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","wisdom":"madrun wisdom","coverage":"madrun coverage","fix:lint":"madrun fix:lint","test:dts":"madrun test:dts","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/supertape.git","type":"git"},"_npmVersion":"11.4.2","description":"supertape stub operator","directories":{},"_nodeVersion":"25.2.1","dependencies":{"@cloudcmd/stub":"^5.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","eslint":"^9.1.1","madrun":"^12.1.0","putout":"^41.0.2","nodemon":"^3.0.1","check-dts":"^0.9.0","supertape":"^12.0.0","typescript":"^5.1.6","mock-require":"^3.0.2","eslint-plugin-putout":"^29.0.2"},"_npmOperationalInternal":{"tmp":"tmp/operator-stub_4.0.0_1768168181639_0.8588263574721084","host":"s3://npm-registry-packages-npm-production"},"readme":"# @supertape/operator-stub [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/supertape.svg?style=flat&longCache=true\n[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/supertape/master.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/supertape \"npm\"\n[BuildStatusURL]: https://travis-ci.org/coderaiser/supertape \"Build Status\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/supertape?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/supertape/badge.svg?branch=master&service=github\n\n`supertape` operator simplifies work with [@cloudcmd/stub](https://github.com/cloudcmd/stub).\n\n## Install\n\n```\nnpm i @supertape/operator-stub -D\n```\n\n## Operators\n\nAdds next operators to work with:\n\n### t.calledWith(fn, args [, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function call', (t) => {\n    const fn = stub();\n    \n    fn('hello', 'world');\n    \n    t.calledWith(fn, ['hello', 'world'], 'fn should be called with \"hello\", \"world\"');\n    t.end();\n});\n```\n\n### t.calledWithNoArgs(fn[, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called with no args', (t) => {\n    const fn = stub();\n    \n    fn();\n    \n    t.calledWithNoArgs(fn);\n    t.end();\n});\n```\n\n### t.calledCount(fn, count[, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called count', (t) => {\n    const fn = stub();\n    \n    fn();\n    fn();\n    \n    t.calledCount(fn, 2);\n    t.end();\n});\n```\n\n### t.calledOnce(fn [, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called once', (t) => {\n    const fn = stub();\n    \n    fn('hello');\n    \n    t.calledOnce(fn);\n    t.end();\n});\n```\n\n### t.calledTwice(fn, count[, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called twice', (t) => {\n    const fn = stub();\n    \n    fn('hello');\n    fn('world');\n    \n    t.calledTwice(fn);\n    t.end();\n});\n```\n\n### t.calledWithNew(fn, count[, message])\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called with new', (t) => {\n    const fn = stub();\n    \n    new fn();\n    \n    t.calledWithNew(fn);\n    t.end();\n});\n```\n\n### t.calledBefore(fn1, fn2[, message])\n\nCheck that `fn1` called before `fn2`.\nDo not forget to set names of stubs.\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called with new', (t) => {\n    const init = stub().withName('init');\n    const show = stub().withName('show');\n    \n    init();\n    show();\n    \n    t.calledBefore(show, init);\n    t.end();\n});\n```\n\n### t.calledAfter(fn1, fn2[, message])\n\nCheck that `fn1` called after `fn2`.\nDo not forget to set names of stubs.\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called with new', (t) => {\n    const init = stub().withName('init');\n    const show = stub().withName('show');\n    \n    init();\n    show();\n    \n    t.calledAfter(init, show);\n    t.end();\n});\n```\n\n### t.calledInOrder([fn1, fn2, fnN][, message])\n\nCheck that array of stubs `fns` called in order;\nDo not forget to set names of stubs.\n\n```js\nimport test, {stub} from 'supertape';\n\ntest('function called with new', (t) => {\n    const init = stub().withName('init');\n    const show = stub().withName('show');\n    \n    init();\n    show();\n    \n    t.calledInOrder([init, show]);\n    t.end();\n});\n```\n\n## License\n\nMIT\n","publish_time":1768168181769,"_cnpm_publish_time":1768168181769,"dist-tags":{"latest":"4.1.0"}}