pax_global_header00006660000000000000000000000064131015247140014510gustar00rootroot0000000000000052 comment=9aa5a73a30b0aaa2d465ea9a70ba479912a98719 sinon-chai-2.10.0/000077500000000000000000000000001310152471400136205ustar00rootroot00000000000000sinon-chai-2.10.0/.gitignore000066400000000000000000000000521310152471400156050ustar00rootroot00000000000000/node_modules/ /npm-debug.log /coverage/ sinon-chai-2.10.0/.jshintrc000066400000000000000000000006571310152471400154550ustar00rootroot00000000000000{ "bitwise": true, "camelcase": true, "curly": true, "eqeqeq": true, "globalstrict": true, "immed": true, "indent": 4, "latedef": "nofunc", "maxlen": 120, "newcap": true, "noarg": true, "node": true, "nonew": true, "quotmark": "double", "trailing": true, "undef": true, "unused": true, "white": true, "predef": [ "define", "chai" ] } sinon-chai-2.10.0/.travis.yml000066400000000000000000000007041310152471400157320ustar00rootroot00000000000000language: node_js node_js: - "0.10" - stable env: # Can't figure out how to DRY this up: http://stackoverflow.com/q/22397300/3191 - CHAI_VERSION=^1.9.2 SINON_VERSION=^1.4.0 - CHAI_VERSION=^2.0.0 SINON_VERSION=^1.4.0 - CHAI_VERSION=^3.0.0 SINON_VERSION=^1.4.0 - CHAI_VERSION=^1.9.2 SINON_VERSION=^2.1.0 - CHAI_VERSION=^2.0.0 SINON_VERSION=^2.1.0 - CHAI_VERSION=^3.0.0 SINON_VERSION=^2.1.0 script: npm run lint && npm run test-travis sinon-chai-2.10.0/LICENSE.txt000066400000000000000000000040771310152471400154530ustar00rootroot00000000000000Dual licensed under WTFPL and BSD: --- Copyright © 2012–2017 Domenic Denicola This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See below for more details. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. --- Copyright © 2012–2017, Domenic Denicola All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sinon-chai-2.10.0/README.md000066400000000000000000000161221310152471400151010ustar00rootroot00000000000000# Sinon.JS Assertions for Chai **Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][] spy, stub, and mocking framework with the [Chai][] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS. Instead of using Sinon.JS's assertions: ```javascript sinon.assertCalledWith(mySpy, "foo"); ``` or awkwardly trying to use Chai's `should` or `expect` interfaces on spy properties: ```javascript mySpy.calledWith("foo").should.be.ok; expect(mySpy.calledWith("foo")).to.be.ok; ``` you can say ```javascript mySpy.should.have.been.calledWith("foo"); expect(mySpy).to.have.been.calledWith("foo"); ``` ## Assertions All of your favorite Sinon.JS assertions made their way into Sinon–Chai. We show the `should` syntax here; the `expect` equivalent is also available.
Sinon.JS property/method Sinon–Chai assertion
called spy.should.have.been.called
callCount spy.should.have.callCount(n)
calledOnce spy.should.have.been.calledOnce
calledTwice spy.should.have.been.calledTwice
calledThrice spy.should.have.been.calledThrice
calledBefore spy1.should.have.been.calledBefore(spy2)
calledAfter spy1.should.have.been.calledAfter(spy2)
calledImmediatelyBefore spy.should.have.been.calledImmediatelyBefore(spy2)
calledImmediatelyAfter spy.should.have.been.calledImmediatelyAfter(spy2)
calledWithNew spy.should.have.been.calledWithNew
alwaysCalledWithNew spy.should.always.have.been.calledWithNew
calledOn spy.should.have.been.calledOn(context)
alwaysCalledOn spy.should.always.have.been.calledOn(context)
calledWith spy.should.have.been.calledWith(...args)
alwaysCalledWith spy.should.always.have.been.calledWith(...args)
calledWithExactly spy.should.have.been.calledWithExactly(...args)
alwaysCalledWithExactly spy.should.always.have.been.calledWithExactly(...args)
calledWithMatch spy.should.have.been.calledWithMatch(...args)
alwaysCalledWithMatch spy.should.always.have.been.calledWithMatch(...args)
returned spy.should.have.returned(returnVal)
alwaysReturned spy.should.have.always.returned(returnVal)
threw spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing)
alwaysThrew spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing)
For more information on the behavior of each assertion, see [the documentation for the corresponding spy methods][spymethods]. These of course work on not only spies, but individual spy calls, stubs, and mocks as well. Note that you can negate any assertion with Chai's `.not`. E. g. for `notCalled` use `spy.should.have.not.been.called`. 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`: ```javascript var chai = require("chai"); var sinon = require("sinon"); sinon.assert.expose(chai.assert, { prefix: "" }); ``` ## Examples Using Chai's `should`: ```javascript "use strict"; var chai = require("chai"); var sinon = require("sinon"); var sinonChai = require("sinon-chai"); chai.should(); chai.use(sinonChai); function hello(name, cb) { cb("hello " + name); } describe("hello", function () { it("should call callback with correct greeting", function () { var cb = sinon.spy(); hello("foo", cb); cb.should.have.been.calledWith("hello foo"); }); }); ``` Using Chai's `expect`: ```javascript "use strict"; var chai = require("chai"); var sinon = require("sinon"); var sinonChai = require("sinon-chai"); var expect = chai.expect; chai.use(sinonChai); function hello(name, cb) { cb("hello " + name); } describe("hello", function () { it("should call callback with correct greeting", function () { var cb = sinon.spy(); hello("foo", cb); expect(cb).to.have.been.calledWith("hello foo"); }); }); ``` ## Installation and Usage ### Node Do an `npm install sinon-chai` to get up and running. Then: ```javascript var chai = require("chai"); var sinonChai = require("sinon-chai"); chai.use(sinonChai); ``` You can of course put this code in a common test fixture file; for an example using [Mocha][], see [the Sinon–Chai tests themselves][fixturedemo]. ### AMD Sinon–Chai supports being used as an [AMD][] module, registering itself anonymously (just like Chai). So, assuming you have configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `"chai"` and `"sinon-chai"`, you can use them as follows: ```javascript define(function (require, exports, module) { var chai = require("chai"); var sinonChai = require("sinon-chai"); chai.use(sinonChai); }); ``` ### ` ``` ### Ruby on Rails Thanks to [Cymen Vig][], there's now [a Ruby gem][] of Sinon–Chai that integrates it with the Rails asset pipeline! [Sinon.JS]: http://sinonjs.org/ [Chai]: http://chaijs.com/ [spymethods]: http://sinonjs.org/docs/#spies-api [sinonassertions]: http://sinonjs.org/docs/#assertions [Mocha]: https://mochajs.org/ [fixturedemo]: https://github.com/domenic/sinon-chai/tree/master/test/ [AMD]: https://github.com/amdjs/amdjs-api/wiki/AMD [Cymen Vig]: https://github.com/cymen [a Ruby gem]: https://github.com/cymen/sinon-chai-rails sinon-chai-2.10.0/lib/000077500000000000000000000000001310152471400143665ustar00rootroot00000000000000sinon-chai-2.10.0/lib/sinon-chai.js000066400000000000000000000126261310152471400167630ustar00rootroot00000000000000(function (sinonChai) { "use strict"; // Module systems magic dance. /* istanbul ignore else */ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { // NodeJS module.exports = sinonChai; } else if (typeof define === "function" && define.amd) { // AMD define(function () { return sinonChai; }); } else { // Other environment (usually