{"_id":"chai-assert-change","_rev":"5-f9f121de61115505270d854f7c55b51c","name":"chai-assert-change","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"chai-assert-change","version":"1.0.0","description":"an assertion against a change to a value","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/amireh/chai-assert-change.git"},"keywords":["chai","assertion","assert","test"],"author":{"name":"Ahmad Amireh"},"license":"MIT","bugs":{"url":"https://github.com/amireh/chai-assert-change/issues"},"homepage":"https://github.com/amireh/chai-assert-change#readme","gitHead":"769bcab2ece2a45608b8b8d8c1c84bfa4fdade77","_id":"chai-assert-change@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"amireh","email":"ahmad@amireh.net"},"dist":{"integrity":"sha512-a0z+MjPGarHoDfwjBJze5sHnRPuon8n4OpmVripkVfeRyzrq09fte3UXbauiigA+797wpOEYCoHueTO8JiGjWA==","shasum":"f980d6a11722730483d25ac1fc0430b2a60c9602","tarball":"https://registry.npmjs.org/chai-assert-change/-/chai-assert-change-1.0.0.tgz","fileCount":2,"unpackedSize":4144,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEach2zHT7SZqkg8Ctr7lT0eIw51IR89sRYvB7p8B4+mAiEA4yJukNuUIhio4kYM6AgunzlIek5v0sNrEkp9hiwaxXA="}]},"maintainers":[{"name":"amireh","email":"ahmad@amireh.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-assert-change_1.0.0_1519686400439_0.42193051864894393"},"_hasShrinkwrap":false},"1.1.0":{"name":"chai-assert-change","version":"1.1.0","description":"an assertion against a change to a value","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/amireh/chai-assert-change.git"},"keywords":["chai","assertion","assert","test"],"author":{"name":"Ahmad Amireh"},"license":"MIT","bugs":{"url":"https://github.com/amireh/chai-assert-change/issues"},"homepage":"https://github.com/amireh/chai-assert-change#readme","gitHead":"ce710b0b6e5f14ada74a613e70aa1d184bb30e88","_id":"chai-assert-change@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"amireh","email":"ahmad@amireh.net"},"dist":{"integrity":"sha512-gO7gtNjxF0W+n2atJOk/siFcaJ27i/LvHOKOwbWtSdlgmuPLN2WNpLFAvwAnvOBi3NGuI4QYa5y1sT0HoCofcA==","shasum":"23e47752e53e6c3f7892b27129e59bbd429b3a40","tarball":"https://registry.npmjs.org/chai-assert-change/-/chai-assert-change-1.1.0.tgz","fileCount":3,"unpackedSize":4494,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkKkZ7w1qST6xTwZVUD6q/iYgqbgoOyikyStaQdSPXHAIhAOzmatMBy2/JYQU4pTzMJiJpunJA37M6xCZx905LrUld"}]},"maintainers":[{"name":"amireh","email":"ahmad@amireh.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-assert-change_1.1.0_1519852285334_0.8039979386912546"},"_hasShrinkwrap":false},"2.0.0":{"name":"chai-assert-change","version":"2.0.0","description":"an assertion against a change to a value","main":"index.js","scripts":{"lint":"eslint index.js test.js","test":"mocha test.js","test:coverage":"nyc npm test","prepublish":"npm run lint && npm run test"},"files":["index.js","CHANGES.md","README.md"],"repository":{"type":"git","url":"git+https://github.com/amireh/chai-assert-change.git"},"keywords":["chai","assertion","assert","test"],"author":{"name":"Ahmad Amireh"},"license":"MIT","bugs":{"url":"https://github.com/amireh/chai-assert-change/issues"},"homepage":"https://github.com/amireh/chai-assert-change#readme","devDependencies":{"chai":"4.1.2","eslint":"4.18.2","mocha":"5.0.1","nyc":"11.4.1"},"peerDependencies":{"chai":"2 || 3 || 4"},"dependencies":{"invariant":"2.2.3"},"nyc":{"check-coverage":true,"per-file":false,"lines":100,"statements":100,"functions":100,"branches":100,"reporter":["html","text-summary"],"all":true},"gitHead":"54319f269ad52910d398cdc2e46b3621d4f24423","_id":"chai-assert-change@2.0.0","_npmVersion":"5.7.1","_nodeVersion":"8.9.4","_npmUser":{"name":"amireh","email":"ahmad@amireh.net"},"dist":{"integrity":"sha512-iyKa71R7ytLkq1ufVt0L06bt/0o/UTOK7YQ12ZbZa8+vjs/Q+wzQ6mv9I0dGYUZJ9SEtDAZHD1L2/TC4olURzg==","shasum":"a4d55317e5afc673248d379578ec645b8c6643ec","tarball":"https://registry.npmjs.org/chai-assert-change/-/chai-assert-change-2.0.0.tgz","fileCount":4,"unpackedSize":9255,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDYo/Qrmo8WweyqeV3W4Hmm9te4ARxVC1wO43OrRJoSJAIgS7Ko/VAhbCdSbL0/6tyFpoxi2t7VKNE3z3t2zXqidQo="}]},"maintainers":[{"name":"amireh","email":"ahmad@amireh.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-assert-change_2.0.0_1520253888052_0.5462639883727836"},"_hasShrinkwrap":false},"2.0.1":{"name":"chai-assert-change","version":"2.0.1","description":"an assertion against a change to a value","main":"index.js","scripts":{"lint":"eslint index.js test.js","test":"mocha test.js","test:coverage":"nyc npm test","prepublish":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/amireh/chai-assert-change.git"},"keywords":["chai","assertion","assert","test"],"author":{"name":"Ahmad Amireh"},"license":"MIT","bugs":{"url":"https://github.com/amireh/chai-assert-change/issues"},"homepage":"https://github.com/amireh/chai-assert-change#readme","devDependencies":{"chai":"4.1.2","eslint":"4.18.2","mocha":"5.0.1","nyc":"11.4.1"},"peerDependencies":{"chai":">= 2"},"dependencies":{"invariant":"2.2.3"},"nyc":{"check-coverage":true,"per-file":false,"lines":100,"statements":100,"functions":100,"branches":100,"reporter":["html","text-summary"],"all":true},"_id":"chai-assert-change@2.0.1","gitHead":"54319f269ad52910d398cdc2e46b3621d4f24423","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"integrity":"sha512-J7bv4sYJFrUy42I7nxvPfi9/lH013Q9BW+uYZrsn6qhmfzvMI/pKy0A4Zcmho27EId/M7ACFBF8bf/t9ZVlzdg==","shasum":"5379656a9a2845790d6c2a171550cc313f589337","tarball":"https://registry.npmjs.org/chai-assert-change/-/chai-assert-change-2.0.1.tgz","fileCount":4,"unpackedSize":9248,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7amP+ChMcixh/1PYtyw00/V8dsIuI7j71abX2E59SRQIhALMPDtBXIA78k8gVziF0/GlvuYooUUhTG9wUWLLPui2e"}]},"_npmUser":{"name":"amireh","email":"ahmad@amireh.net"},"directories":{},"maintainers":[{"name":"amireh","email":"ahmad@amireh.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-assert-change_2.0.1_1715970078933_0.07636759494651568"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-26T23:06:40.439Z","1.0.0":"2018-02-26T23:06:40.509Z","modified":"2024-05-17T18:21:19.286Z","1.1.0":"2018-02-28T21:11:25.409Z","2.0.0":"2018-03-05T12:44:48.105Z","2.0.1":"2024-05-17T18:21:19.080Z"},"maintainers":[{"name":"amireh","email":"ahmad@amireh.net"}],"description":"an assertion against a change to a value","homepage":"https://github.com/amireh/chai-assert-change#readme","keywords":["chai","assertion","assert","test"],"repository":{"type":"git","url":"git+https://github.com/amireh/chai-assert-change.git"},"author":{"name":"Ahmad Amireh"},"bugs":{"url":"https://github.com/amireh/chai-assert-change/issues"},"license":"MIT","readme":"# chai-assert-change\n\nAn assertion for [chai.js](http://chaijs.com/) to test the side-effects of a\nfunction.\n\n## Installation\n\n    npm install --save-dev chai-assert-change\n\nYou do need `chai` to be installed.\n\n## API\n\n```javascript\nfunction assertChange({\n  // The function that applies the side-effect.\n  // \n  // If this yields a Promise, we'll run the queries only once it resolves.\n  // We'll also propagate it back for you so that you can feed it to mocha\n  // or whatever else.\n  fn: function(): Any | Promise.<Any>,\n\n  // A function that returns the value we're inspecting. That is, the expected\n  // side-effect of the function.\n  of: function(value: Any): Any,\n\n  // A custom message to append to the assertion error to help you\n  // trace the assertion.\n  ?it: String,\n\n  // --- QUERIES ---\n  // You can use only one of these for each side-effect you're testing.\n\n  // [1] [by]\n  // \n  // Test a change in a numerical value, like \"X changes by 2\" or\n  // \"X changes by 0\" as in it does not change.\n  ?by: Number,\n\n  // [2] [from, to]\n  // \n  // Test non-numerical values for inequality; arrays, objects, or numbers\n  // too when a delta doesn't make sense.\n  // \n  // It is implemented using:\n  // \n  //     chai.assert.deepEqual(a, b)\n  // \n  // To use this you need to fill in both \"from\" and \"to\".\n  ?from: Any,\n  ?to: Any,\n\n  // [3] [custom]\n  // \n  // A custom test; you are passed the values before and after applying\n  // the side-effect function and it's up to you to do the assertions.\n  ?using: function(initialValue: Any, nextValue: Any): void\n}): Any | Promise.<Any>\n```\n\nTo test more than one side-effect you can define the `in` property as an array\nof the tests. So the `fn` property remains at the root but the rest of the\nproperties go inside the `in` entries.\n\nExamples are shown in the next section.\n\n## Usage examples\n\n### Testing a single side-effect\n\n```javascript\nimport assertChange from 'chai-assert-change'\n\nlet x = 0\n\nassertChange({\n  fn: () => { x += 1 },\n  of: () => x,\n  by: 1\n})\n```\n\n### Testing multiple side-effects\n\n```javascript\nlet x = 0\nlet y = 0\n\nassertChange({\n  fn: () => { x += 1 },\n  in: [\n    {\n      it: 'increments X',\n      of: () => x,\n      by: 1\n    },\n    {\n      it: 'does not touch Y',\n      of: () => y,\n      by: 0\n    }\n  ]\n})\n```\n\nNotice how we used `it` to label the tests. These will be used in the assertion\nmessage if it fails to hold.\n\n### Testing a deferred side-effect (Promise)\n\nThe following example shows how the assertion will run the tests only after\na promise resolves which is useful in async scenarios.\n\n```javascript\nit('navigates', function() {\n  return assertChange({\n    fn: () => router.navigate('/b'),\n    of: () => location.pathname,\n    from: '/a',\n    to: '/b'\n  })\n})\n```\n\nThe promise is yielded back to you (with the value it resolved with) so that\nyou can throw it back to your testing framework.\n\n### Testing using a custom assertion\n\nYou can implement the `using` hook to perform any kind of test instead of\ninequality. Personally I'd recommend against this because it's more difficult\nto reason about but sometimes it's necessary when, for example, dealing with\ndeeply nested structures.\n\n```javascript\nassertChange({\n  fn: () => ...,\n  of: () => ...,\n  using: (a, b) => {\n    assert.notInclude(a, { foo: '1' })\n    assert.include(b, { foo: '1' })\n  }\n})\n```\n\n## License\n\nMIT","readmeFilename":"README.md"}