Skip to content

Commit a80597d

Browse files
author
ChaiJs Bot
committed
(data): Auto build _data
1 parent 91733fe commit a80597d

5 files changed

Lines changed: 190 additions & 390 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_id":"@joethefkingfrypan/sinon-chai","name":"@joethefkingfrypan/sinon-chai","dist-tags":{"latest":"3.6.0-rc1"},"versions":{"3.6.0-rc1":{"name":"@joethefkingfrypan/sinon-chai","description":"Extends Chai with assertions for the Sinon.JS mocking framework.","keywords":["chai","chai-plugin","browser","vendor","mocks-and-spies","sinon","testing","spies","stubs","mocks"],"version":"3.6.0-rc1","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"contributors":[{"name":"Simon de Lang","email":"simondelang@gmail.com"}],"license":"(BSD-2-Clause OR WTFPL)","repository":{"type":"git","url":"git+https://github.com/domenic/sinon-chai.git"},"main":"./lib/sinon-chai.js","scripts":{"test":"mocha","test-travis":"npm install && npm install chai@$CHAI_VERSION && npm install sinon@$SINON_VERSION && npm test","lint":"eslint .","cover":"nyc --reporter=html mocha && opener ./coverage/sinon-chai.js.html"},"peerDependencies":{"chai":"^4.0.0","sinon":">=4.0.0 <10.0.0"},"devDependencies":{"chai":"^4.2.0","eslint":"^6.8.0","mocha":"^7.0.1","nyc":"^15.0.0","opener":"^1.5.1","sinon":"^9.0.0"},"gitHead":"71adb7a600c7c71a082343a4f50c0d8159bbb1c3","bugs":{"url":"https://github.com/domenic/sinon-chai/issues"},"homepage":"https://github.com/domenic/sinon-chai#readme","_id":"@joethefkingfrypan/sinon-chai@3.6.0-rc1","_nodeVersion":"14.16.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-N/H//zl2lXkjT596rUsH6qGSxgTK+Q039vUB17lUkUhGSYMEmOnzPdpHksCq7t89gDxbMaK1vrkYrBZaGJw0BA==","shasum":"49f5c27c2b3f9daca85dd61dc2ebfe41713e29c5","tarball":"https://registry.npmjs.org/@joethefkingfrypan/sinon-chai/-/sinon-chai-3.6.0-rc1.tgz","fileCount":5,"unpackedSize":17055,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVJpACRA9TVsSAnZWagAAITsP/1AcBvsbefwQvM7WNN30\nXTiGGj/13QEBbWaUP2VUcOFGGLvmWgq18vqrrectXdjCWisg7lk7IPTRtuoC\nQiiCVSTMg2ofosZHWAgC7GIV8/si+D9QpvYK00Wh/M9jFpWtu/nsLwsBxOOO\nxl1iCfjI6AzetfnuY+WUJezyp/tHaK6Tps5SJ8HU+ILLMHWpl4dDp0P9irmm\nSYgnjm7R9qDMX1L98tf/fVcMUPqwm4tUrpE2n0051Mh+un8vWb+1vYVMNOtP\nE4Stt3wNL+tXV8jdMWIbxLbnSq1pbuXs4kEhejeY0SsAKNMTstJNUH32bkEz\nbru6e4n2Yu88XSD0+0nGSF/dYwkK9q+H5HdDa5+C/3hvBjOs2MwnXr2VGwwm\n/jGnbI5j4WjjJi8HrB86JNFyO5FJBsYcnRF90/fbXAS6rOMD09WjnkXwIpq/\nEpg2Mo9/fLFda3z7rr2S6LD0Qjc4YvyWZdAbGb/qJxiS6ZrKDXx67AMRIb1G\n+b/sWKqKF4QP9AkEWGaYiOt5/0AgTLcVgd3YgF5lmTNqsU9VgPwh7gEvGR7P\nU7DY2l04tWMaLlBL+VG/VvivpcQgN1KXb74LOM5LJZtPe47NxWJl6yMwYu2O\nqUTLfLKSJFiYVL7tacXHtSCq282nRk2NvsBwqJ/VzSCvawlbSLf3lUr8uWMt\nwDEo\r\n=wi1x\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"joethefkingfrypan","email":"romgagnaire@gmail.com"},"directories":{},"maintainers":[{"name":"joethefkingfrypan","email":"romgagnaire@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sinon-chai_3.6.0-rc1_1616157247895_0.31494147285411933"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-19T12:34:07.854Z","3.6.0-rc1":"2021-03-19T12:34:08.009Z","modified":"2021-03-19T12:34:11.731Z"},"maintainers":[{"name":"joethefkingfrypan","email":"romgagnaire@gmail.com"}],"description":"Extends Chai with assertions for the Sinon.JS mocking framework.","homepage":"https://github.com/domenic/sinon-chai#readme","keywords":["chai","chai-plugin","browser","vendor","mocks-and-spies","sinon","testing","spies","stubs","mocks"],"repository":{"type":"git","url":"git+https://github.com/domenic/sinon-chai.git"},"contributors":[{"name":"Simon de Lang","email":"simondelang@gmail.com"}],"author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"bugs":{"url":"https://github.com/domenic/sinon-chai/issues"},"license":"(BSD-2-Clause OR WTFPL)","readme":"# Sinon.JS Assertions for Chai\n\n**Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][] spy, stub, and mocking framework with the\n[Chai][] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS.\n\nInstead of using Sinon.JS's assertions:\n\n```javascript\nsinon.assert.calledWith(mySpy, \"foo\");\n```\n\nor awkwardly trying to use Chai's `should` or `expect` interfaces on spy properties:\n\n```javascript\nmySpy.calledWith(\"foo\").should.be.ok;\nexpect(mySpy.calledWith(\"foo\")).to.be.ok;\n```\n\nyou can say\n\n```javascript\nmySpy.should.have.been.calledWith(\"foo\");\nexpect(mySpy).to.have.been.calledWith(\"foo\");\n```\n\n## Assertions\n\nAll of your favorite Sinon.JS assertions made their way into Sinon–Chai. We show the `should` syntax here; the `expect`\nequivalent is also available.\n\n| Sinon.JS property/method | Sinon–Chai assertion |\n|--------------------------|-------------------------------------------------------------------|\n| called | spy.should.have.been.called |\n| callCount | spy.should.have.callCount(n) |\n| calledOnce | spy.should.have.been.calledOnce |\n| calledTwice | spy.should.have.been.calledTwice |\n| calledThrice | spy.should.have.been.calledThrice |\n| calledBefore | spy1.should.have.been.calledBefore(spy2) |\n| calledAfter | spy1.should.have.been.calledAfter(spy2) |\n| calledImmediatelyBefore | spy.should.have.been.calledImmediatelyBefore(spy2) |\n| calledImmediatelyAfter | spy.should.have.been.calledImmediatelyAfter(spy2) |\n| calledWithNew | spy.should.have.been.calledWithNew |\n| alwaysCalledWithNew | spy.should.always.have.been.calledWithNew |\n| calledOn | spy.should.have.been.calledOn(context) |\n| alwaysCalledOn | spy.should.always.have.been.calledOn(context) |\n| calledWith | spy.should.have.been.calledWith(...args) |\n| alwaysCalledWith | spy.should.always.have.been.calledWith(...args) |\n| calledOnceWith | spy.should.always.have.been.calledOnceWith(...args) |\n| calledWithExactly | spy.should.have.been.calledWithExactly(...args) |\n| alwaysCalledWithExactly | spy.should.always.have.been.calledWithExactly(...args) |\n| calledOnceWithExactly | spy.should.always.have.been.calledOnceWithExactly(...args) |\n| calledWithMatch | spy.should.have.been.calledWithMatch(...args) |\n| alwaysCalledWithMatch | spy.should.always.have.been.calledWithMatch(...args) |\n| returned | spy.should.have.returned(returnVal) |\n| alwaysReturned | spy.should.have.always.returned(returnVal) |\n| threw | spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing) |\n| alwaysThrew | spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing) |\n\nFor more information on the behavior of each assertion, see\n[the documentation for the corresponding spy methods][spymethods]. These of course work on not only spies, but\nindividual spy calls, stubs, and mocks as well.\n\nNote that you can negate any assertion with Chai's `.not`. E. g. for `notCalled` use `spy.should.have.not.been.called`.\n\nFor `assert` interface there is no need for this library. You can install [Sinon.JS assertions][sinonassertions] right into Chai's `assert` object with `expose`:\n\n```javascript\nvar chai = require(\"chai\");\nvar sinon = require(\"sinon\");\n\nsinon.assert.expose(chai.assert, { prefix: \"\" });\n```\n\n## Examples\n\nUsing Chai's `should`:\n\n```javascript\n\"use strict\";\nvar chai = require(\"chai\");\nvar sinon = require(\"sinon\");\nvar sinonChai = require(\"sinon-chai\");\nchai.should();\nchai.use(sinonChai);\n\nfunction hello(name, cb) {\n cb(\"hello \" + name);\n}\n\ndescribe(\"hello\", function () {\n it(\"should call callback with correct greeting\", function () {\n var cb = sinon.spy();\n\n hello(\"foo\", cb);\n\n cb.should.have.been.calledWith(\"hello foo\");\n });\n});\n```\n\nUsing Chai's `expect`:\n\n```javascript\n\"use strict\";\nvar chai = require(\"chai\");\nvar sinon = require(\"sinon\");\nvar sinonChai = require(\"sinon-chai\");\nvar expect = chai.expect;\nchai.use(sinonChai);\n\nfunction hello(name, cb) {\n cb(\"hello \" + name);\n}\n\ndescribe(\"hello\", function () {\n it(\"should call callback with correct greeting\", function () {\n var cb = sinon.spy();\n\n hello(\"foo\", cb);\n\n expect(cb).to.have.been.calledWith(\"hello foo\");\n });\n});\n```\n\n## Installation and Usage\n\n### Node\n\nDo an `npm install --save-dev sinon-chai` to get up and running. Then:\n\n```javascript\nvar chai = require(\"chai\");\nvar sinonChai = require(\"sinon-chai\");\n\nchai.use(sinonChai);\n```\n\nYou can of course put this code in a common test fixture file; for an example using [Mocha][], see\n[the Sinon–Chai tests themselves][fixturedemo].\n\n### AMD\n\nSinon–Chai supports being used as an [AMD][] module, registering itself anonymously (just like Chai). So, assuming you\nhave configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `\"chai\"` and\n`\"sinon-chai\"`, you can use them as follows:\n\n```javascript\ndefine(function (require, exports, module) {\n var chai = require(\"chai\");\n var sinonChai = require(\"sinon-chai\");\n\n chai.use(sinonChai);\n});\n```\n\n### `<script>` tag\n\nIf you include Sinon–Chai directly with a `<script>` tag, after the one for Chai itself, then it will automatically plug\nin to Chai and be ready for use. Note that you'll want to get the latest browser build of Sinon.JS as well:\n\n```html\n<script src=\"chai.js\"></script>\n<script src=\"sinon-chai.js\"></script>\n<script src=\"sinon.js\"></script>\n```\n\n### Ruby on Rails\n\nThanks to [Cymen Vig][], there's now [a Ruby gem][] of Sinon–Chai that integrates it with the Rails asset pipeline!\n\n\n[Sinon.JS]: http://sinonjs.org/\n[Chai]: http://chaijs.com/\n[spymethods]: http://sinonjs.org/docs/#spies-api\n[sinonassertions]: http://sinonjs.org/docs/#assertions\n[Mocha]: https://mochajs.org/\n[fixturedemo]: https://github.com/domenic/sinon-chai/tree/master/test/\n[AMD]: https://github.com/amdjs/amdjs-api/wiki/AMD\n[Cymen Vig]: https://github.com/cymen\n[a Ruby gem]: https://github.com/cymen/sinon-chai-rails\n","readmeFilename":"README.md"}

_data/plugins/chai_jq.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_data/plugins/chai_openapi_response_validator.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
layout: plugin
3+
permalink: plugins/@joethefkingfrypan/sinon-chai/
4+
pluginName: @joethefkingfrypan/sinon-chai
5+
---
6+
7+
# Sinon.JS Assertions for Chai
8+
9+
**Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][] spy, stub, and mocking framework with the
10+
[Chai][] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS.
11+
12+
Instead of using Sinon.JS's assertions:
13+
14+
```javascript
15+
sinon.assert.calledWith(mySpy, "foo");
16+
```
17+
18+
or awkwardly trying to use Chai's `should` or `expect` interfaces on spy properties:
19+
20+
```javascript
21+
mySpy.calledWith("foo").should.be.ok;
22+
expect(mySpy.calledWith("foo")).to.be.ok;
23+
```
24+
25+
you can say
26+
27+
```javascript
28+
mySpy.should.have.been.calledWith("foo");
29+
expect(mySpy).to.have.been.calledWith("foo");
30+
```
31+
32+
## Assertions
33+
34+
All of your favorite Sinon.JS assertions made their way into Sinon–Chai. We show the `should` syntax here; the `expect`
35+
equivalent is also available.
36+
37+
| Sinon.JS property/method | Sinon–Chai assertion |
38+
|--------------------------|-------------------------------------------------------------------|
39+
| called | spy.should.have.been.called |
40+
| callCount | spy.should.have.callCount(n) |
41+
| calledOnce | spy.should.have.been.calledOnce |
42+
| calledTwice | spy.should.have.been.calledTwice |
43+
| calledThrice | spy.should.have.been.calledThrice |
44+
| calledBefore | spy1.should.have.been.calledBefore(spy2) |
45+
| calledAfter | spy1.should.have.been.calledAfter(spy2) |
46+
| calledImmediatelyBefore | spy.should.have.been.calledImmediatelyBefore(spy2) |
47+
| calledImmediatelyAfter | spy.should.have.been.calledImmediatelyAfter(spy2) |
48+
| calledWithNew | spy.should.have.been.calledWithNew |
49+
| alwaysCalledWithNew | spy.should.always.have.been.calledWithNew |
50+
| calledOn | spy.should.have.been.calledOn(context) |
51+
| alwaysCalledOn | spy.should.always.have.been.calledOn(context) |
52+
| calledWith | spy.should.have.been.calledWith(...args) |
53+
| alwaysCalledWith | spy.should.always.have.been.calledWith(...args) |
54+
| calledOnceWith | spy.should.always.have.been.calledOnceWith(...args) |
55+
| calledWithExactly | spy.should.have.been.calledWithExactly(...args) |
56+
| alwaysCalledWithExactly | spy.should.always.have.been.calledWithExactly(...args) |
57+
| calledOnceWithExactly | spy.should.always.have.been.calledOnceWithExactly(...args) |
58+
| calledWithMatch | spy.should.have.been.calledWithMatch(...args) |
59+
| alwaysCalledWithMatch | spy.should.always.have.been.calledWithMatch(...args) |
60+
| returned | spy.should.have.returned(returnVal) |
61+
| alwaysReturned | spy.should.have.always.returned(returnVal) |
62+
| threw | spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing) |
63+
| alwaysThrew | spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing) |
64+
65+
For more information on the behavior of each assertion, see
66+
[the documentation for the corresponding spy methods][spymethods]. These of course work on not only spies, but
67+
individual spy calls, stubs, and mocks as well.
68+
69+
Note that you can negate any assertion with Chai's `.not`. E. g. for `notCalled` use `spy.should.have.not.been.called`.
70+
71+
For `assert` interface there is no need for this library. You can install [Sinon.JS assertions][sinonassertions] right into Chai's `assert` object with `expose`:
72+
73+
```javascript
74+
var chai = require("chai");
75+
var sinon = require("sinon");
76+
77+
sinon.assert.expose(chai.assert, { prefix: "" });
78+
```
79+
80+
## Examples
81+
82+
Using Chai's `should`:
83+
84+
```javascript
85+
"use strict";
86+
var chai = require("chai");
87+
var sinon = require("sinon");
88+
var sinonChai = require("sinon-chai");
89+
chai.should();
90+
chai.use(sinonChai);
91+
92+
function hello(name, cb) {
93+
cb("hello " + name);
94+
}
95+
96+
describe("hello", function () {
97+
it("should call callback with correct greeting", function () {
98+
var cb = sinon.spy();
99+
100+
hello("foo", cb);
101+
102+
cb.should.have.been.calledWith("hello foo");
103+
});
104+
});
105+
```
106+
107+
Using Chai's `expect`:
108+
109+
```javascript
110+
"use strict";
111+
var chai = require("chai");
112+
var sinon = require("sinon");
113+
var sinonChai = require("sinon-chai");
114+
var expect = chai.expect;
115+
chai.use(sinonChai);
116+
117+
function hello(name, cb) {
118+
cb("hello " + name);
119+
}
120+
121+
describe("hello", function () {
122+
it("should call callback with correct greeting", function () {
123+
var cb = sinon.spy();
124+
125+
hello("foo", cb);
126+
127+
expect(cb).to.have.been.calledWith("hello foo");
128+
});
129+
});
130+
```
131+
132+
## Installation and Usage
133+
134+
### Node
135+
136+
Do an `npm install --save-dev sinon-chai` to get up and running. Then:
137+
138+
```javascript
139+
var chai = require("chai");
140+
var sinonChai = require("sinon-chai");
141+
142+
chai.use(sinonChai);
143+
```
144+
145+
You can of course put this code in a common test fixture file; for an example using [Mocha][], see
146+
[the Sinon–Chai tests themselves][fixturedemo].
147+
148+
### AMD
149+
150+
Sinon–Chai supports being used as an [AMD][] module, registering itself anonymously (just like Chai). So, assuming you
151+
have configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `"chai"` and
152+
`"sinon-chai"`, you can use them as follows:
153+
154+
```javascript
155+
define(function (require, exports, module) {
156+
var chai = require("chai");
157+
var sinonChai = require("sinon-chai");
158+
159+
chai.use(sinonChai);
160+
});
161+
```
162+
163+
### `<script>` tag
164+
165+
If you include Sinon–Chai directly with a `<script>` tag, after the one for Chai itself, then it will automatically plug
166+
in to Chai and be ready for use. Note that you'll want to get the latest browser build of Sinon.JS as well:
167+
168+
```html
169+
<script src="chai.js"></script>
170+
<script src="sinon-chai.js"></script>
171+
<script src="sinon.js"></script>
172+
```
173+
174+
### Ruby on Rails
175+
176+
Thanks to [Cymen Vig][], there's now [a Ruby gem][] of Sinon–Chai that integrates it with the Rails asset pipeline!
177+
178+
179+
[Sinon.JS]: http://sinonjs.org/
180+
[Chai]: http://chaijs.com/
181+
[spymethods]: http://sinonjs.org/docs/#spies-api
182+
[sinonassertions]: http://sinonjs.org/docs/#assertions
183+
[Mocha]: https://mochajs.org/
184+
[fixturedemo]: https://github.com/domenic/sinon-chai/tree/master/test/
185+
[AMD]: https://github.com/amdjs/amdjs-api/wiki/AMD
186+
[Cymen Vig]: https://github.com/cymen
187+
[a Ruby gem]: https://github.com/cymen/sinon-chai-rails

0 commit comments

Comments
 (0)