pax_global_header00006660000000000000000000000064131270315000014502gustar00rootroot0000000000000052 comment=e237fd24a47924c6a625df7bbde2ae40783f7c6f chai-as-promised-7.1.1/000077500000000000000000000000001312703150000146355ustar00rootroot00000000000000chai-as-promised-7.1.1/.editorconfig000066400000000000000000000002651312703150000173150ustar00rootroot00000000000000root = true [*] end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 indent_style = space indent_size = 4 [.eslintrc.json] indent_size = 2 chai-as-promised-7.1.1/.eslintignore000066400000000000000000000000121312703150000173310ustar00rootroot00000000000000coverage/ chai-as-promised-7.1.1/.eslintrc.json000066400000000000000000000172141312703150000174360ustar00rootroot00000000000000{ "root": true, "env": { "node": true, "es6": true }, "parserOptions": { "ecmaVersion": 6 }, "rules": { // Possible errors "comma-dangle": ["error", "never"], "no-cond-assign": ["error", "except-parens"], "no-console": "error", "no-constant-condition": "error", "no-control-regex": "error", "no-debugger": "error", "no-dupe-args": "error", "no-dupe-keys": "error", "no-duplicate-case": "error", "no-empty": "error", "no-empty-character-class": "error", "no-ex-assign": "error", "no-extra-boolean-cast": "error", "no-extra-parens": ["error", "all", { "conditionalAssign": false, "nestedBinaryExpressions": false }], "no-extra-semi": "error", "no-func-assign": "error", "no-inner-declarations": "off", "no-invalid-regexp": "error", "no-irregular-whitespace": "error", "no-negated-in-lhs": "error", "no-obj-calls": "error", "no-regex-spaces": "error", "no-sparse-arrays": "error", "no-unexpected-multiline": "error", "no-unreachable": "error", "no-unsafe-finally": "off", "use-isnan": "error", "valid-jsdoc": "off", "valid-typeof": "error", // Best practices "accessor-pairs": "error", "array-callback-return": "error", "block-scoped-var": "off", "complexity": "off", "consistent-return": "error", "curly": ["error", "all"], "default-case": "off", "dot-location": ["error", "property"], "dot-notation": "error", "eqeqeq": "error", "guard-for-in": "off", "no-alert": "error", "no-caller": "error", "no-case-declarations": "error", "no-div-regex": "off", "no-else-return": "error", "no-empty-function": "error", "no-empty-pattern": "error", "no-eq-null": "error", "no-eval": "error", "no-extend-native": "error", "no-extra-bind": "error", "no-extra-label": "error", "no-fallthrough": "error", "no-floating-decimal": "error", "no-implicit-coercion": "error", "no-implicit-globals": "error", "no-implied-eval": "off", "no-invalid-this": "error", "no-iterator": "error", "no-labels": ["error", { "allowLoop": true }], "no-lone-blocks": "error", "no-loop-func": "off", "no-magic-numbers": "off", "no-multi-spaces": "error", "no-multi-str": "error", "no-native-reassign": "error", "no-new": "error", "no-new-func": "error", "no-new-wrappers": "error", "no-octal": "error", "no-octal-escape": "error", "no-param-reassign": "off", "no-process-env": "error", "no-proto": "error", "no-redeclare": "error", "no-return-assign": ["error", "except-parens"], "no-script-url": "off", "no-self-assign": "error", "no-self-compare": "error", "no-sequences": "error", "no-throw-literal": "error", "no-unmodified-loop-condition": "error", "no-unused-expressions": "error", "no-unused-labels": "error", "no-useless-call": "error", "no-useless-concat": "error", "no-useless-escape": "error", "no-void": "error", "no-warning-comments": "off", "no-with": "error", "radix": ["error", "as-needed"], "vars-on-top": "off", "wrap-iife": ["error", "outside"], "yoda": ["error", "never"], // Strict Mode "strict": ["error", "global"], // Variables "init-declarations": "off", "no-catch-shadow": "error", "no-delete-var": "error", "no-label-var": "error", "no-restricted-globals": "off", "no-shadow": "error", "no-shadow-restricted-names": "error", "no-undef": "error", "no-undef-init": "error", "no-undefined": "off", "no-unused-vars": "error", "no-use-before-define": ["error", "nofunc"], // Node.js and CommonJS "callback-return": "off", "global-require": "error", "handle-callback-err": "error", "no-mixed-requires": ["error", true], "no-new-require": "error", "no-path-concat": "error", "no-process-exit": "error", "no-restricted-imports": "off", "no-restricted-modules": "off", "no-sync": "off", // Stylistic Issues "array-bracket-spacing": ["error", "never"], "block-spacing": ["error", "always"], "brace-style": ["error", "1tbs", { "allowSingleLine": false }], "camelcase": ["error", { "properties": "always" }], "comma-spacing": ["error", { "before": false, "after": true }], "comma-style": ["error", "last"], "computed-property-spacing": ["error", "never"], "consistent-this": "off", "eol-last": "error", "func-names": "off", "func-style": ["error", "declaration"], "id-blacklist": "off", "id-length": "off", "id-match": "off", "indent": ["error", 4, { "SwitchCase": 1 }], "jsx-quotes": "off", "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }], "keyword-spacing": ["error", { "before": true, "after": true }], "linebreak-style": ["error", "unix"], "lines-around-comment": "off", "max-depth": "off", "max-len": ["error", 120, { "ignoreUrls": true }], "max-nested-callbacks": "off", "max-params": "off", "max-statements": "off", "max-statements-per-line": ["error", { "max": 1 }], "new-cap": "error", "new-parens": "error", "newline-after-var": "off", "newline-before-return": "off", "newline-per-chained-call": "off", "no-array-constructor": "error", "no-bitwise": "off", "no-continue": "off", "no-inline-comments": "off", "no-lonely-if": "error", "no-mixed-spaces-and-tabs": "error", "no-multiple-empty-lines": "error", "no-negated-condition": "off", "no-nested-ternary": "error", "no-new-object": "error", "no-plusplus": "off", "no-restricted-syntax": "off", "no-spaced-func": "error", "no-ternary": "off", "no-trailing-spaces": "error", "no-underscore-dangle": "off", "no-unneeded-ternary": "error", "no-whitespace-before-property": "error", "object-curly-spacing": ["error", "always"], "one-var": ["error", "never"], "one-var-declaration-per-line": ["error", "initializations"], "operator-assignment": ["error", "always"], "operator-linebreak": ["error", "after"], "padded-blocks": ["error", "never"], "quote-props": ["error", "as-needed"], "quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }], "require-jsdoc": "off", "semi": ["error", "always"], "semi-spacing": "error", "sort-imports": "off", "sort-vars": "off", "space-before-blocks": ["error", "always"], "space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }], "space-in-parens": ["error", "never"], "space-infix-ops": "error", "space-unary-ops": ["error", { "words": true, "nonwords": false }], "spaced-comment": ["error", "always", { "markers": ["///"] }], "wrap-regex": "off", // ECMAScript 6 "arrow-body-style": "off", // meh "arrow-parens": ["error", "as-needed"], "arrow-spacing": "error", "constructor-super": "error", "generator-star-spacing": ["error", "after"], "no-class-assign": "error", "no-confusing-arrow": "off", "no-const-assign": "error", "no-dupe-class-members": "error", "no-duplicate-imports": "error", "no-new-symbol": "error", "no-this-before-super": "error", "no-useless-computed-key": "error", "no-useless-constructor": "error", "no-var": "error", "object-shorthand": "error", "prefer-arrow-callback": "error", "prefer-const": "error", "prefer-reflect": "off", "prefer-rest-params": "off", "prefer-spread": "off", "prefer-template": "off", "require-yield": "error", "template-curly-spacing": ["error", "never"], "yield-star-spacing": ["error", "after"] } } chai-as-promised-7.1.1/.gitignore000066400000000000000000000001051312703150000166210ustar00rootroot00000000000000/node_modules/ /npm-debug.log /coverage/ /test/browser/output.html chai-as-promised-7.1.1/.travis.yml000066400000000000000000000002721312703150000167470ustar00rootroot00000000000000sudo: false language: node_js node_js: - 4 - stable env: - CHAI_VERSION=^2.1.2 - CHAI_VERSION=^3.0.0 - CHAI_VERSION=^4.0.0 script: - npm run lint - npm run test-travis chai-as-promised-7.1.1/LICENSE.txt000066400000000000000000000013361312703150000164630ustar00rootroot00000000000000Copyright © 2012–2016 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. chai-as-promised-7.1.1/README.md000066400000000000000000000251121312703150000161150ustar00rootroot00000000000000 Promises/A+ logo # Chai Assertions for Promises **Chai as Promised** extends [Chai](http://chaijs.com/) with a fluent language for asserting facts about [promises](http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript). Instead of manually wiring up your expectations to a promise's fulfilled and rejected handlers: ```javascript doSomethingAsync().then( function (result) { result.should.equal("foo"); done(); }, function (err) { done(err); } ); ``` you can write code that expresses what you really mean: ```javascript return doSomethingAsync().should.eventually.equal("foo"); ``` or if you have a case where `return` is not preferable (e.g. style considerations) or not possible (e.g. the testing framework doesn't allow returning promises to signal asynchronous test completion), then you can use the following workaround (where `done()` is supplied by the test framework): ```javascript doSomethingAsync().should.eventually.equal("foo").notify(done); ``` *Notice*: either `return` or `notify(done)` _must_ be used with promise assertions. This can be a slight departure from the existing format of assertions being used on a project or by a team. Those other assertions are likely synchronous and thus do not require special handling. ## How to Use ### `should`/`expect` Interface The most powerful extension provided by Chai as Promised is the `eventually` property. With it, you can transform any existing Chai assertion into one that acts on a promise: ```javascript (2 + 2).should.equal(4); // becomes return Promise.resolve(2 + 2).should.eventually.equal(4); expect({ foo: "bar" }).to.have.property("foo"); // becomes return expect(Promise.resolve({ foo: "bar" })).to.eventually.have.property("foo"); ``` There are also a few promise-specific extensions (with the usual `expect` equivalents also available): ```javascript return promise.should.be.fulfilled; return promise.should.eventually.deep.equal("foo"); return promise.should.become("foo"); // same as `.eventually.deep.equal` return promise.should.be.rejected; return promise.should.be.rejectedWith(Error); // other variants of Chai's `throw` assertion work too. ``` ### `assert` Interface As with the `should`/`expect` interface, Chai as Promised provides an `eventually` extender to `chai.assert`, allowing any existing Chai assertion to be used on a promise: ```javascript assert.equal(2 + 2, 4, "This had better be true"); // becomes return assert.eventually.equal(Promise.resolve(2 + 2), 4, "This had better be true, eventually"); ``` And there are, of course, promise-specific extensions: ```javascript return assert.isFulfilled(promise, "optional message"); return assert.becomes(promise, "foo", "optional message"); return assert.doesNotBecome(promise, "foo", "optional message"); return assert.isRejected(promise, "optional message"); return assert.isRejected(promise, Error, "optional message"); return assert.isRejected(promise, /error message matcher/, "optional message"); ``` ### Progress Callbacks Chai as Promised does not have any intrinsic support for testing promise progress callbacks. The properties you would want to test are probably much better suited to a library like [Sinon.JS](http://sinonjs.org/), perhaps in conjunction with [Sinon–Chai](https://github.com/domenic/sinon-chai): ```javascript var progressSpy = sinon.spy(); return promise.then(null, null, progressSpy).then(function () { progressSpy.should.have.been.calledWith("33%"); progressSpy.should.have.been.calledWith("67%"); progressSpy.should.have.been.calledThrice; }); ``` ### Customizing Output Promises By default, the promises returned by Chai as Promised's assertions are regular Chai assertion objects, extended with a single `then` method derived from the input promise. To change this behavior, for instance to output a promise with more useful sugar methods such as are found in most promise libraries, you can override `chaiAsPromised.transferPromiseness`. Here's an example that transfer's Q's `finally` and `done` methods: ```js chaiAsPromised.transferPromiseness = function (assertion, promise) { assertion.then = promise.then.bind(promise); // this is all you get by default assertion.finally = promise.finally.bind(promise); assertion.done = promise.done.bind(promise); }; ``` ### Transforming Arguments to the Asserters Another advanced customization hook Chai as Promised allows is if you want to transform the arguments to the asserters, possibly asynchronously. Here is a toy example: ```js chaiAsPromised.transformAsserterArgs = function (args) { return args.map(function (x) { return x + 1; }); } Promise.resolve(2).should.eventually.equal(2); // will now fail! Promise.resolve(3).should.eventually.equal(2); // will now pass! ``` The transform can even be asynchronous, returning a promise for an array instead of an array directly. An example of that might be using `Promise.all` so that an array of promises becomes a promise for an array. If you do that, then you can compare promises against other promises using the asserters: ```js // This will normally fail, since within() only works on numbers. Promise.resolve(2).should.eventually.be.within(Promise.resolve(1), Promise.resolve(6)); chaiAsPromised.transformAsserterArgs = function (args) { return Promise.all(args); }; // But now it will pass, since we transformed the array of promises for numbers into // (a promise for) an array of numbers Promise.resolve(2).should.eventually.be.within(Promise.resolve(1), Promise.resolve(6)); ``` ### Compatibility Chai as Promised is compatible with all promises following the [Promises/A+ specification](http://promisesaplus.com/). Notably, jQuery's promises were not up to spec before jQuery 3.0, and Chai as Promised will not work with them. In particular, Chai as Promised makes extensive use of the standard [transformation behavior](http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/#toc_2) of `then`, which jQuery<3.0 does not support. Angular promises have a special digest cycle for their processing, and [need extra setup code to work with Chai as Promised](http://stackoverflow.com/a/37374041/3191). ### Working with Non-Promise–Friendly Test Runners Some test runners (e.g. Jasmine, QUnit, or tap/tape) do not have the ability to use the returned promise to signal asynchronous test completion. If possible, I'd recommend switching to ones that do, such as [Mocha](http://mochajs.org/#asynchronous-code), [Buster](http://docs.busterjs.org/en/latest/modules/buster-test/spec/#returning-a-promise), or [blue-tape](https://github.com/spion/blue-tape). But if that's not an option, Chai as Promised still has you covered. As long as your test framework takes a callback indicating when the asynchronous test run is over, Chai as Promised can adapt to that situation with its `notify` method, like so: ```javascript it("should be fulfilled", function (done) { promise.should.be.fulfilled.and.notify(done); }); it("should be rejected", function (done) { otherPromise.should.be.rejected.and.notify(done); }); ``` In these examples, if the conditions are not met, the test runner will receive an error of the form `"expected promise to be fulfilled but it was rejected with [Error: error message]"`, or `"expected promise to be rejected but it was fulfilled."` There's another form of `notify` which is useful in certain situations, like doing assertions after a promise is complete. For example: ```javascript it("should change the state", function (done) { otherState.should.equal("before"); promise.should.be.fulfilled.then(function () { otherState.should.equal("after"); }).should.notify(done); }); ``` Notice how `.notify(done)` is hanging directly off of `.should`, instead of appearing after a promise assertion. This indicates to Chai as Promised that it should pass fulfillment or rejection directly through to the testing framework. Thus, the above code will fail with a Chai as Promised error (`"expected promise to be fulfilled…"`) if `promise` is rejected, but will fail with a simple Chai error (`expected "before" to equal "after"`) if `otherState` does not change. ### Multiple Promise Assertions To perform assertions on multiple promises, use `Promise.all` to combine multiple Chai as Promised assertions: ```javascript it("should all be well", function () { return Promise.all([ promiseA.should.become("happy"), promiseB.should.eventually.have.property("fun times"), promiseC.should.be.rejectedWith(TypeError, "only joyful types are allowed") ]); }); ``` This will pass any failures of the individual promise assertions up to the test framework, instead of wrapping them in an `"expected promise to be fulfilled…"` message as would happen if you did `return Promise.all([…]).should.be.fulfilled`. If you can't use `return`, then use `.should.notify(done)`, similar to the previous examples. ## Installation and Setup ### Node Do an `npm install chai-as-promised` to get up and running. Then: ```javascript var chai = require("chai"); var chaiAsPromised = require("chai-as-promised"); chai.use(chaiAsPromised); // Then either: var expect = chai.expect; // or: var assert = chai.assert; // or: chai.should(); // according to your preference of assertion style ``` You can of course put this code in a common test fixture file; for an example using [Mocha](http://mochajs.org), see [the Chai as Promised tests themselves](https://github.com/domenic/chai-as-promised/tree/master/test/). **Note when using other Chai plugins:** Chai as Promised finds all currently-registered asserters and promisifies them, at the time it is installed. Thus, you should install Chai as Promised _last_, after any other Chai plugins, if you expect their asserters to be promisified. ### In the Browser To use Chai as Promised in environments that don't support Node.js-like CommonJS modules, you'll need to use a bundling tool like [browserify](http://browserify.org/). See also the note below about browser compatibility. ### Karma If you're using [Karma](https://karma-runner.github.io/), check out the accompanying [karma-chai-as-promised](https://github.com/vlkosinov/karma-chai-as-promised) plugin. ### Browser/Node Compatibility Chai as Promised requires Node v4+ or a browser with equivalent support for modern JavaScript syntax. If your browser doesn't support modern JavaScript syntax, you'll need to transpile it down using a tool like [Babel](http://babeljs.io/). chai-as-promised-7.1.1/lib/000077500000000000000000000000001312703150000154035ustar00rootroot00000000000000chai-as-promised-7.1.1/lib/chai-as-promised.js000066400000000000000000000352631312703150000210770ustar00rootroot00000000000000"use strict"; /* eslint-disable no-invalid-this */ let checkError = require("check-error"); module.exports = (chai, utils) => { const Assertion = chai.Assertion; const assert = chai.assert; const proxify = utils.proxify; // If we are using a version of Chai that has checkError on it, // we want to use that version to be consistent. Otherwise, we use // what was passed to the factory. if (utils.checkError) { checkError = utils.checkError; } function isLegacyJQueryPromise(thenable) { // jQuery promises are Promises/A+-compatible since 3.0.0. jQuery 3.0.0 is also the first version // to define the catch method. return typeof thenable.catch !== "function" && typeof thenable.always === "function" && typeof thenable.done === "function" && typeof thenable.fail === "function" && typeof thenable.pipe === "function" && typeof thenable.progress === "function" && typeof thenable.state === "function"; } function assertIsAboutPromise(assertion) { if (typeof assertion._obj.then !== "function") { throw new TypeError(utils.inspect(assertion._obj) + " is not a thenable."); } if (isLegacyJQueryPromise(assertion._obj)) { throw new TypeError("Chai as Promised is incompatible with thenables of jQuery<3.0.0, sorry! Please " + "upgrade jQuery or use another Promises/A+ compatible library (see " + "http://promisesaplus.com/)."); } } function proxifyIfSupported(assertion) { return proxify === undefined ? assertion : proxify(assertion); } function method(name, asserter) { utils.addMethod(Assertion.prototype, name, function () { assertIsAboutPromise(this); return asserter.apply(this, arguments); }); } function property(name, asserter) { utils.addProperty(Assertion.prototype, name, function () { assertIsAboutPromise(this); return proxifyIfSupported(asserter.apply(this, arguments)); }); } function doNotify(promise, done) { promise.then(() => done(), done); } // These are for clarity and to bypass Chai refusing to allow `undefined` as actual when used with `assert`. function assertIfNegated(assertion, message, extra) { assertion.assert(true, null, message, extra.expected, extra.actual); } function assertIfNotNegated(assertion, message, extra) { assertion.assert(false, message, null, extra.expected, extra.actual); } function getBasePromise(assertion) { // We need to chain subsequent asserters on top of ones in the chain already (consider // `eventually.have.property("foo").that.equals("bar")`), only running them after the existing ones pass. // So the first base-promise is `assertion._obj`, but after that we use the assertions themselves, i.e. // previously derived promises, to chain off of. return typeof assertion.then === "function" ? assertion : assertion._obj; } function getReasonName(reason) { return reason instanceof Error ? reason.toString() : checkError.getConstructorName(reason); } // Grab these first, before we modify `Assertion.prototype`. const propertyNames = Object.getOwnPropertyNames(Assertion.prototype); const propertyDescs = {}; for (const name of propertyNames) { propertyDescs[name] = Object.getOwnPropertyDescriptor(Assertion.prototype, name); } property("fulfilled", function () { const derivedPromise = getBasePromise(this).then( value => { assertIfNegated(this, "expected promise not to be fulfilled but it was fulfilled with #{act}", { actual: value }); return value; }, reason => { assertIfNotNegated(this, "expected promise to be fulfilled but it was rejected with #{act}", { actual: getReasonName(reason) }); return reason; } ); module.exports.transferPromiseness(this, derivedPromise); return this; }); property("rejected", function () { const derivedPromise = getBasePromise(this).then( value => { assertIfNotNegated(this, "expected promise to be rejected but it was fulfilled with #{act}", { actual: value }); return value; }, reason => { assertIfNegated(this, "expected promise not to be rejected but it was rejected with #{act}", { actual: getReasonName(reason) }); // Return the reason, transforming this into a fulfillment, to allow further assertions, e.g. // `promise.should.be.rejected.and.eventually.equal("reason")`. return reason; } ); module.exports.transferPromiseness(this, derivedPromise); return this; }); method("rejectedWith", function (errorLike, errMsgMatcher, message) { let errorLikeName = null; const negate = utils.flag(this, "negate") || false; // rejectedWith with that is called without arguments is // the same as a plain ".rejected" use. if (errorLike === undefined && errMsgMatcher === undefined && message === undefined) { /* eslint-disable no-unused-expressions */ return this.rejected; /* eslint-enable no-unused-expressions */ } if (message !== undefined) { utils.flag(this, "message", message); } if (errorLike instanceof RegExp || typeof errorLike === "string") { errMsgMatcher = errorLike; errorLike = null; } else if (errorLike && errorLike instanceof Error) { errorLikeName = errorLike.toString(); } else if (typeof errorLike === "function") { errorLikeName = checkError.getConstructorName(errorLike); } else { errorLike = null; } const everyArgIsDefined = Boolean(errorLike && errMsgMatcher); let matcherRelation = "including"; if (errMsgMatcher instanceof RegExp) { matcherRelation = "matching"; } const derivedPromise = getBasePromise(this).then( value => { let assertionMessage = null; let expected = null; if (errorLike) { assertionMessage = "expected promise to be rejected with #{exp} but it was fulfilled with #{act}"; expected = errorLikeName; } else if (errMsgMatcher) { assertionMessage = `expected promise to be rejected with an error ${matcherRelation} #{exp} but ` + `it was fulfilled with #{act}`; expected = errMsgMatcher; } assertIfNotNegated(this, assertionMessage, { expected, actual: value }); return value; }, reason => { const errorLikeCompatible = errorLike && (errorLike instanceof Error ? checkError.compatibleInstance(reason, errorLike) : checkError.compatibleConstructor(reason, errorLike)); const errMsgMatcherCompatible = errMsgMatcher && checkError.compatibleMessage(reason, errMsgMatcher); const reasonName = getReasonName(reason); if (negate && everyArgIsDefined) { if (errorLikeCompatible && errMsgMatcherCompatible) { this.assert(true, null, "expected promise not to be rejected with #{exp} but it was rejected " + "with #{act}", errorLikeName, reasonName); } } else { if (errorLike) { this.assert(errorLikeCompatible, "expected promise to be rejected with #{exp} but it was rejected with #{act}", "expected promise not to be rejected with #{exp} but it was rejected " + "with #{act}", errorLikeName, reasonName); } if (errMsgMatcher) { this.assert(errMsgMatcherCompatible, `expected promise to be rejected with an error ${matcherRelation} #{exp} but got ` + `#{act}`, `expected promise not to be rejected with an error ${matcherRelation} #{exp}`, errMsgMatcher, checkError.getMessage(reason)); } } return reason; } ); module.exports.transferPromiseness(this, derivedPromise); return this; }); property("eventually", function () { utils.flag(this, "eventually", true); return this; }); method("notify", function (done) { doNotify(getBasePromise(this), done); return this; }); method("become", function (value, message) { return this.eventually.deep.equal(value, message); }); // ### `eventually` // We need to be careful not to trigger any getters, thus `Object.getOwnPropertyDescriptor` usage. const methodNames = propertyNames.filter(name => { return name !== "assert" && typeof propertyDescs[name].value === "function"; }); methodNames.forEach(methodName => { Assertion.overwriteMethod(methodName, originalMethod => function () { return doAsserterAsyncAndAddThen(originalMethod, this, arguments); }); }); const getterNames = propertyNames.filter(name => { return name !== "_obj" && typeof propertyDescs[name].get === "function"; }); getterNames.forEach(getterName => { // Chainable methods are things like `an`, which can work both for `.should.be.an.instanceOf` and as // `should.be.an("object")`. We need to handle those specially. const isChainableMethod = Assertion.prototype.__methods.hasOwnProperty(getterName); if (isChainableMethod) { Assertion.overwriteChainableMethod( getterName, originalMethod => function () { return doAsserterAsyncAndAddThen(originalMethod, this, arguments); }, originalGetter => function () { return doAsserterAsyncAndAddThen(originalGetter, this); } ); } else { Assertion.overwriteProperty(getterName, originalGetter => function () { return proxifyIfSupported(doAsserterAsyncAndAddThen(originalGetter, this)); }); } }); function doAsserterAsyncAndAddThen(asserter, assertion, args) { // Since we're intercepting all methods/properties, we need to just pass through if they don't want // `eventually`, or if we've already fulfilled the promise (see below). if (!utils.flag(assertion, "eventually")) { asserter.apply(assertion, args); return assertion; } const derivedPromise = getBasePromise(assertion).then(value => { // Set up the environment for the asserter to actually run: `_obj` should be the fulfillment value, and // now that we have the value, we're no longer in "eventually" mode, so we won't run any of this code, // just the base Chai code that we get to via the short-circuit above. assertion._obj = value; utils.flag(assertion, "eventually", false); return args ? module.exports.transformAsserterArgs(args) : args; }).then(newArgs => { asserter.apply(assertion, newArgs); // Because asserters, for example `property`, can change the value of `_obj` (i.e. change the "object" // flag), we need to communicate this value change to subsequent chained asserters. Since we build a // promise chain paralleling the asserter chain, we can use it to communicate such changes. return assertion._obj; }); module.exports.transferPromiseness(assertion, derivedPromise); return assertion; } // ### Now use the `Assertion` framework to build an `assert` interface. const originalAssertMethods = Object.getOwnPropertyNames(assert).filter(propName => { return typeof assert[propName] === "function"; }); assert.isFulfilled = (promise, message) => (new Assertion(promise, message)).to.be.fulfilled; assert.isRejected = (promise, errorLike, errMsgMatcher, message) => { const assertion = new Assertion(promise, message); return assertion.to.be.rejectedWith(errorLike, errMsgMatcher, message); }; assert.becomes = (promise, value, message) => assert.eventually.deepEqual(promise, value, message); assert.doesNotBecome = (promise, value, message) => assert.eventually.notDeepEqual(promise, value, message); assert.eventually = {}; originalAssertMethods.forEach(assertMethodName => { assert.eventually[assertMethodName] = function (promise) { const otherArgs = Array.prototype.slice.call(arguments, 1); let customRejectionHandler; const message = arguments[assert[assertMethodName].length - 1]; if (typeof message === "string") { customRejectionHandler = reason => { throw new chai.AssertionError(`${message}\n\nOriginal reason: ${utils.inspect(reason)}`); }; } const returnedPromise = promise.then( fulfillmentValue => assert[assertMethodName].apply(assert, [fulfillmentValue].concat(otherArgs)), customRejectionHandler ); returnedPromise.notify = done => { doNotify(returnedPromise, done); }; return returnedPromise; }; }); }; module.exports.transferPromiseness = (assertion, promise) => { assertion.then = promise.then.bind(promise); }; module.exports.transformAsserterArgs = values => values; chai-as-promised-7.1.1/package-lock.json000066400000000000000000001261701312703150000200600ustar00rootroot00000000000000{ "name": "chai-as-promised", "version": "7.1.1", "lockfileVersion": 1, "dependencies": { "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", "dev": true }, "acorn": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", "integrity": "sha1-xGDfCEkUY/AozLguqzcwvwEIez0=", "dev": true }, "acorn-jsx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "dependencies": { "acorn": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", "dev": true } } }, "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "dev": true }, "ajv-keywords": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", "dev": true }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, "ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", "dev": true }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, "argparse": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", "dev": true }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true }, "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", "dev": true }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, "assertion-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", "dev": true }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, "babel-code-frame": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", "dev": true }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true }, "browser-stdout": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", "dev": true }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true }, "callsites": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", "dev": true, "optional": true }, "center-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", "dev": true, "optional": true }, "chai": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/chai/-/chai-4.0.2.tgz", "integrity": "sha1-L3MnxN5vOF3XeHmZ4qsCaXoyuDs=", "dev": true }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" }, "circular-json": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.1.tgz", "integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=", "dev": true }, "cli-cursor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true }, "cli-width": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=", "dev": true }, "cliui": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", "dev": true, "optional": true, "dependencies": { "wordwrap": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", "dev": true, "optional": true } } }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "dev": true }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "commander": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "concat-stream": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", "dev": true }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true }, "debug": { "version": "2.6.8", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "dev": true }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true, "optional": true }, "deep-eql": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-2.0.2.tgz", "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", "dev": true, "dependencies": { "type-detect": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-3.0.0.tgz", "integrity": "sha1-RtDMhVOrt7E6NSsNbeov1Y8tm1U=", "dev": true } } }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, "del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true }, "diff": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", "dev": true }, "doctrine": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", "dev": true }, "es5-ext": { "version": "0.10.23", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.23.tgz", "integrity": "sha1-dXi1G+l0IHpUh4IbVlOMIk5Oezg=", "dev": true }, "es6-iterator": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", "dev": true }, "es6-map": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", "dev": true }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", "dev": true }, "es6-symbol": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true }, "es6-weak-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, "escodegen": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "dependencies": { "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, "estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", "dev": true } } }, "escope": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", "dev": true }, "eslint": { "version": "3.19.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", "dev": true }, "espree": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", "dev": true }, "esprima": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", "dev": true }, "esquery": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", "dev": true }, "esrecurse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", "dev": true }, "estraverse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true }, "exit-hook": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", "dev": true }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true }, "file-entry-cache": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true }, "flat-cache": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", "dev": true }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "generate-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", "dev": true }, "generate-object-property": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", "dev": true }, "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", "dev": true }, "globby": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true }, "growl": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", "dev": true }, "handlebars": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", "dev": true, "dependencies": { "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true } } }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true }, "has-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, "ignore": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz", "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=", "dev": true }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "inquirer": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", "dev": true }, "interpret": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz", "integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A=", "dev": true }, "is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", "dev": true }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true }, "is-my-json-valid": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz", "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=", "dev": true }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", "dev": true }, "is-path-in-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", "dev": true }, "is-path-inside": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", "dev": true }, "is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", "dev": true }, "is-resolvable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", "dev": true }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "istanbul": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "dependencies": { "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, "glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true } } }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "dev": true }, "js-yaml": { "version": "3.8.4", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz", "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=", "dev": true }, "json-stable-stringify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true }, "json3": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", "dev": true }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, "jsonpointer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true }, "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", "dev": true, "optional": true }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true }, "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, "lodash._baseassign": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", "dev": true }, "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "dev": true }, "lodash._basecreate": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", "dev": true }, "lodash._getnative": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", "dev": true }, "lodash._isiterateecall": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", "dev": true }, "lodash.create": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", "dev": true }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", "dev": true }, "lodash.isarray": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", "dev": true }, "lodash.keys": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", "dev": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true }, "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true }, "mocha": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.4.2.tgz", "integrity": "sha1-0O9NMyEm2/GNDWQMmzgt1IvpdZQ=", "dev": true, "dependencies": { "debug": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz", "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=", "dev": true }, "glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true }, "ms": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", "dev": true }, "supports-color": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", "dev": true } } }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "mute-stream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", "dev": true }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true }, "onetime": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "dependencies": { "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", "dev": true } } }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, "path-is-inside": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true }, "pluralize": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", "dev": true }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, "progress": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true }, "readline2": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", "dev": true }, "rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true }, "resolve": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", "dev": true }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, "restore-cursor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true }, "right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", "dev": true, "optional": true }, "rimraf": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", "dev": true }, "run-async": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", "dev": true }, "rx-lite": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", "dev": true }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "shelljs": { "version": "0.7.8", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", "dev": true }, "slice-ansi": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, "source-map": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", "dev": true, "optional": true }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, "table": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", "dev": true, "dependencies": { "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, "string-width": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.0.tgz", "integrity": "sha1-AwZkVh/BRslCPsfZeP4kV0N/5tA=", "dev": true }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true } } }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, "tryit": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", "dev": true }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true }, "type-detect": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz", "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=", "dev": true }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", "dev": true, "optional": true, "dependencies": { "source-map": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", "dev": true, "optional": true } } }, "uglify-to-browserify": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", "dev": true, "optional": true }, "user-home": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", "dev": true }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", "dev": true }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", "dev": true, "optional": true }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "write": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, "optional": true } } } chai-as-promised-7.1.1/package.json000066400000000000000000000016721312703150000171310ustar00rootroot00000000000000{ "name": "chai-as-promised", "description": "Extends Chai with assertions about promises.", "keywords": [ "chai", "chai-plugin", "browser", "async", "testing", "assertions", "promises", "promises-aplus" ], "version": "7.1.1", "author": "Domenic Denicola (https://domenic.me)", "license": "WTFPL", "repository": "domenic/chai-as-promised", "main": "./lib/chai-as-promised.js", "files": [ "lib" ], "scripts": { "test": "mocha", "test-travis": "npm install chai@$CHAI_VERSION && npm test", "lint": "eslint .", "cover": "istanbul cover node_modules/mocha/bin/_mocha && opener ./coverage/lcov-report/lib/chai-as-promised.js.html" }, "dependencies": { "check-error": "^1.0.2" }, "peerDependencies": { "chai": ">= 2.1.2 < 5" }, "devDependencies": { "chai": "^4.0.2", "eslint": "^3.19.0", "istanbul": "0.4.5", "mocha": "^3.4.2" } } chai-as-promised-7.1.1/test/000077500000000000000000000000001312703150000156145ustar00rootroot00000000000000chai-as-promised-7.1.1/test/.eslintrc.json000066400000000000000000000001311312703150000204030ustar00rootroot00000000000000{ "extends": "../.eslintrc.json", "env": { "mocha": true, "node": true } } chai-as-promised-7.1.1/test/assert-eventually.js000066400000000000000000000125061312703150000216450ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const shouldPass = require("./support/common.js").shouldPass; const shouldFail = require("./support/common.js").shouldFail; const assert = require("chai").assert; const expect = require("chai").expect; describe("Assert interface with eventually extender:", () => { let promise = null; describe("Direct tests of fulfilled promises", () => { it(".eventually.isNull(promise)", done => { assert.eventually.isNull(Promise.resolve(null)).notify(done); }); it(".eventually.isFunction(promise)", done => { assert.eventually.isFunction(Promise.resolve(() => { /* Forever pending */ })).notify(done); }); it(".eventually.typeOf(promise, 'string')", done => { assert.eventually.typeOf(Promise.resolve("hello"), "string").notify(done); }); it(".eventually.include(promiseForString, 'substring')", done => { assert.eventually.include(Promise.resolve("hello"), "hell").notify(done); }); it(".eventually.include(promiseForArray, arrayMember)", done => { assert.eventually.include(Promise.resolve([1, 2, 3]), 1).notify(done); }); }); describe("On a promise fulfilled with the number 42", () => { beforeEach(() => { promise = Promise.resolve(42); }); describe(".eventually.isNull(promise)", () => { shouldFail({ op: () => assert.eventually.isNull(promise), message: "to equal null" }); }); describe(".eventually.isDefined(promise)", () => { shouldPass(() => assert.eventually.isDefined(promise)); }); describe(".eventually.ok(promise)", () => { shouldPass(() => assert.eventually.ok(promise)); }); describe(".eventually.equal(promise, 42)", () => { shouldPass(() => assert.eventually.equal(promise, 42)); }); describe(".eventually.equal(promise, 52)", () => { shouldFail({ op: () => assert.eventually.equal(promise, 52), message: "to equal 52" }); function shouldFailWithCorrectActual(promiseProducer) { it("should return a promise rejected with an assertion error that has actual/expected properties " + "correct", done => { expect(promiseProducer().then( () => { throw new Error("promise fulfilled"); }, e => { e.actual.should.equal(42); e.expected.should.equal(52); } )).to.be.fulfilled.notify(done); }); } describe("assert", () => { shouldFailWithCorrectActual(() => assert.eventually.equal(promise, 52)); }); describe("expect", () => { shouldFailWithCorrectActual(() => expect(promise).to.eventually.equal(52)); }); describe("should", () => { shouldFailWithCorrectActual(() => promise.should.eventually.equal(52)); }); }); describe(".eventually.notEqual(promise, 42)", () => { shouldFail({ op: () => assert.eventually.notEqual(promise, 42), message: "to not equal 42" }); }); describe(".eventually.notEqual(promise, 52)", () => { shouldPass(() => assert.eventually.notEqual(promise, 52)); }); }); describe("On a promise fulfilled with { foo: 'bar' }", () => { beforeEach(() => { promise = Promise.resolve({ foo: "bar" }); }); describe(".eventually.equal(promise, { foo: 'bar' })", () => { shouldFail({ op: () => assert.eventually.equal(promise, { foo: "bar" }), message: "to equal { foo: 'bar' }" }); }); describe(".eventually.deepEqual(promise, { foo: 'bar' })", () => { shouldPass(() => assert.eventually.deepEqual(promise, { foo: "bar" })); }); }); describe("Assertion messages", () => { const message = "He told me enough! He told me you killed him!"; describe("should pass through for .eventually.isNull(promise, message) for fulfilled", () => { shouldFail({ op: () => assert.eventually.isNull(Promise.resolve(42), message), message }); }); describe("should pass through for .eventually.isNull(promise, message) for rejected", () => { shouldFail({ op: () => assert.eventually.isNull(Promise.reject(), message), message }); }); describe("should pass through for .eventually.equal(promise, 52, message) for fulfilled", () => { shouldFail({ op: () => assert.eventually.equal(Promise.resolve(42), 52, message), message }); }); describe("should pass through for .eventually.equal(promise, 52, message) for rejected", () => { shouldFail({ op: () => assert.eventually.equal(Promise.reject(), 52, message), message }); }); }); }); chai-as-promised-7.1.1/test/assert-promise-specific.js000066400000000000000000000252141312703150000227160ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const shouldPass = require("./support/common.js").shouldPass; const shouldFail = require("./support/common.js").shouldFail; const assert = require("chai").assert; describe("Assert interface:", () => { let promise = null; const error = new Error("boo"); const custom = "No. I am your father."; describe("when the promise is fulfilled", () => { beforeEach(() => { promise = Promise.resolve({ foo: "bar" }); }); describe(".isFulfilled(promise)", () => { shouldPass(() => assert.isFulfilled(promise)); }); describe(".becomes(promise, correctValue)", () => { shouldPass(() => assert.becomes(promise, { foo: "bar" })); }); describe(".becomes(promise, incorrectValue)", () => { shouldFail({ op: () => assert.becomes(promise, { baz: "quux" }), message: "to deeply equal { baz: 'quux' }" }); }); describe(".becomes(promise, incorrectValue, custom)", () => { shouldFail({ op: () => assert.becomes(promise, { baz: "quux" }, custom), message: custom }); }); describe(".doesNotBecome(promise, correctValue)", () => { shouldFail({ op: () => assert.doesNotBecome(promise, { foo: "bar" }), message: "to not deeply equal { foo: 'bar' }" }); }); describe(".doesNotBecome(promise, incorrectValue)", () => { shouldPass(() => assert.doesNotBecome(promise, { baz: "quux" })); }); describe(".doesNotBecome(promise, correctValue, custom)", () => { shouldFail({ op: () => assert.doesNotBecome(promise, { foo: "bar" }, custom), message: custom }); }); describe(".isRejected(promise)", () => { shouldFail({ op: () => assert.isRejected(promise), message: "to be rejected" }); }); describe(".isRejected(promise, TypeError)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError), message: "to be rejected" }); }); describe(".isRejected(promise, /regexp/)", () => { shouldFail({ op: () => assert.isRejected(promise, /regexp/), message: "to be rejected" }); }); describe(".isRejected(promise, TypeError, /regexp/)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, /regexp/), message: "to be rejected" }); }); describe(".isRejected(promise, errorInstance)", () => { shouldFail({ op: () => assert.isRejected(promise, error), message: "to be rejected" }); }); // Chai never interprets the 3rd parameter to assert.throws as // a custom error message. This is what we are checking here. describe(".isRejected(promise, /quux/, custom)", () => { shouldFail({ op: () => assert.isRejected(promise, /quux/, custom), notMessage: custom }); }); }); describe("when the promise is rejected", () => { beforeEach(() => { promise = Promise.reject(error); }); describe(".isFulfilled(promise)", () => { shouldFail({ op: () => assert.isFulfilled(promise), message: "to be fulfilled" }); }); describe(".isFulfilled(promise, custom)", () => { shouldFail({ op: () => assert.isFulfilled(promise, custom), message: custom }); }); describe(".isRejected(promise)", () => { shouldPass(() => assert.isRejected(promise)); }); describe(".isRejected(promise, theError)", () => { shouldPass(() => assert.isRejected(promise, error)); }); describe(".isRejected(promise, differentError)", () => { shouldFail({ op: () => assert.isRejected(promise, new Error()), message: "to be rejected with" }); }); // Chai never interprets the 3rd parameter to assert.throws as // a custom error message. This is what we are checking here. describe(".isRejected(promise, differentError, custom)", () => { shouldFail({ op: () => assert.isRejected(promise, new Error(), custom), notMessage: custom }); }); describe("with an Error having message 'foo bar'", () => { beforeEach(() => { promise = Promise.reject(new Error("foo bar")); }); describe(".isRejected(promise, 'bar')", () => { shouldPass(() => assert.isRejected(promise, "bar")); }); describe(".isRejected(promise, 'bar', custom)", () => { shouldPass(() => assert.isRejected(promise, "bar", custom)); }); describe(".isRejected(promise, /bar/)", () => { shouldPass(() => assert.isRejected(promise, /bar/)); }); describe(".isRejected(promise, /bar/, custom)", () => { shouldPass(() => assert.isRejected(promise, /bar/, custom)); }); describe(".isRejected(promise, 'quux')", () => { shouldFail({ op: () => assert.isRejected(promise, "quux"), message: "to be rejected with" }); }); // Chai 3.5.0 never interprets the 3rd parameter to assert.throws as // a custom error message. This is what we are checking here. describe(".isRejected(promise, 'quux', custom)", () => { shouldFail({ op: () => assert.isRejected(promise, "quux", custom), notMessage: custom }); }); describe(".isRejected(promise, /quux/)", () => { shouldFail({ op: () => assert.isRejected(promise, /quux/), message: "to be rejected with" }); }); }); describe("with a RangeError", () => { beforeEach(() => { promise = Promise.reject(new RangeError()); }); describe(".isRejected(promise, RangeError)", () => { shouldPass(() => assert.isRejected(promise, RangeError)); }); describe(".isRejected(promise, TypeError)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError), message: "to be rejected" }); }); }); describe("with a RangeError having a message 'foo bar'", () => { beforeEach(() => { promise = Promise.reject(new RangeError("foo bar")); }); describe(".isRejected(promise, RangeError, 'foo')", () => { shouldPass(() => assert.isRejected(promise, RangeError, "foo")); }); describe(".isRejected(promise, RangeError, /bar/)", () => { shouldPass(() => assert.isRejected(promise, RangeError, /bar/)); }); describe(".isRejected(promise, RangeError, 'quux')", () => { shouldFail({ op: () => assert.isRejected(promise, RangeError, "quux"), message: "to be rejected with an error including 'quux' but got 'foo bar'" }); }); describe(".isRejected(promise, RangeError, /quux/)", () => { shouldFail({ op: () => assert.isRejected(promise, RangeError, /quux/), message: "to be rejected with an error matching /quux/ but got 'foo bar'" }); }); describe(".isRejected(promise, TypeError, 'foo')", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, "foo"), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".isRejected(promise, TypeError, /bar/)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, /bar/), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".isRejected(promise, TypeError, 'quux')", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, "quux"), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".isRejected(promise, TypeError, /quux/)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, /quux/), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".isRejected(promise, RangeError, 'foo', custom)", () => { shouldPass(() => assert.isRejected(promise, RangeError, "foo", custom)); }); describe(".isRejected(promise, RangeError, /bar/, custom)", () => { shouldPass(() => assert.isRejected(promise, RangeError, /bar/, custom)); }); describe(".isRejected(promise, RangeError, 'quux', custom)", () => { shouldFail({ op: () => assert.isRejected(promise, RangeError, "quux", custom), message: custom }); }); describe(".isRejected(promise, RangeError, /quux/, custom)", () => { shouldFail({ op: () => assert.isRejected(promise, RangeError, /quux/, custom), message: custom }); }); describe(".isRejected(promise, RangeError, undefined, custom)", () => { shouldPass(() => assert.isRejected(promise, RangeError, undefined, custom)); }); describe(".isRejected(promise, TypeError, undefined, custom)", () => { shouldFail({ op: () => assert.isRejected(promise, TypeError, undefined, custom), message: custom }); }); }); }); }); chai-as-promised-7.1.1/test/chainable-methods-compat.js000066400000000000000000000020241312703150000230000ustar00rootroot00000000000000"use strict"; const chai = require("chai"); const chaiAsPromised = require(".."); const expect = chai.expect; function newMethod() { // Do nothing } function newMethodChain() { /* eslint-disable no-invalid-this */ return this.assert(this._obj.__property === true); /* eslint-enable no-invalid-this */ } function makeFunction() { function fn() { // Do nothing } fn.__property = true; return fn; } chai.use(ctx => { ctx.Assertion.addChainableMethod("newMethod", newMethod, newMethodChain); }); describe("New method `newMethod` added to chai", () => { describe("before executing chai.use(chaiAsPromised)", () => { it("should work", () => { expect(makeFunction()).to.have.been.newMethod(); }); }); describe("after executing chai.use(chaiAsPromised)", () => { before(() => { chai.use(chaiAsPromised); }); it("should still work", () => { expect(makeFunction()).to.have.been.newMethod(); }); }); }); chai-as-promised-7.1.1/test/configurable-asserter-args.js000066400000000000000000000026411312703150000233750ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const chaiAsPromised = require(".."); const originalTransformAsserterArgs = require("..").transformAsserterArgs; describe("Configuring the way in which asserter arguments are transformed", () => { beforeEach(() => { chaiAsPromised.transformAsserterArgs = Promise.all.bind(Promise); }); afterEach(() => { chaiAsPromised.transformAsserterArgs = originalTransformAsserterArgs; }); it("should override transformAsserterArgs and allow to compare promises", () => { const value = "test it"; return Promise.resolve(value).should.eventually.equal(Promise.resolve(value)); }); it("should override transformAsserterArgs and wait until all promises are resolved", () => { return Promise.resolve(5).should.eventually.be.within(Promise.resolve(3), Promise.resolve(6)); }); it("should not invoke transformAsserterArgs for chai properties", () => { chaiAsPromised.transformAsserterArgs = () => { throw new Error("transformAsserterArgs should not be called for chai properties"); }; return Promise.resolve(true).should.eventually.be.true; }); it("should transform asserter args", () => { chaiAsPromised.transformAsserterArgs = args => { return Array.from(args).map(x => x + 1); }; return Promise.resolve(3).should.eventually.equal(2); }); }); chai-as-promised-7.1.1/test/configurable-promiseness-transfer.js000066400000000000000000000014151312703150000250020ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const chaiAsPromised = require(".."); const originalTransferPromiseness = require("..").transferPromiseness; describe("Configuring the way in which promise-ness is transferred", () => { afterEach(() => { chaiAsPromised.transferPromiseness = originalTransferPromiseness; }); it("should return a promise with the custom modifications applied", () => { chaiAsPromised.transferPromiseness = (assertion, promise) => { assertion.then = promise.then.bind(promise); assertion.isCustomized = true; }; const promise = Promise.resolve("1234"); const assertion = promise.should.become("1234"); assertion.should.have.property("isCustomized", true); }); }); chai-as-promised-7.1.1/test/custom-messages.js000066400000000000000000000026201312703150000212710ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const shouldPass = require("./support/common.js").shouldPass; const shouldFail = require("./support/common.js").shouldFail; describe("Custom messages", () => { let promise = null; const message = "He told me enough! He told me you killed him!"; beforeEach(() => { promise = Promise.resolve(42); }); describe("should pass through for .become(value, message) for 42", () => { shouldPass(() => promise.should.become(42, message)); }); describe("should pass through for .become(value, message) for 52", () => { shouldFail({ op: () => promise.should.become(52, message), message }); }); describe("should pass through for .not.become(42, message)", () => { shouldFail({ op: () => promise.should.not.become(42, message), message }); }); describe("should pass through for .not.become(52, message)", () => { shouldPass(() => promise.should.not.become(52, message)); }); describe("should pass through for .eventually.equal(42)", () => { shouldPass(() => promise.should.eventually.equal(42, message)); }); describe("should pass through for .not.eventually.equal(42)", () => { shouldFail({ op: () => promise.should.not.eventually.equal(42, message), message }); }); }); chai-as-promised-7.1.1/test/proxy-guard.js000066400000000000000000000056451312703150000204450ustar00rootroot00000000000000"use strict"; const chai = require("chai"); const chaiAsPromised = require(".."); chai.should(); chai.use(chaiAsPromised); function shouldGuard(fn, msg) { fn.should.throw("Invalid Chai property: " + msg); } describe("Proxy guard", () => { const number = 42; const promise = Promise.resolve(42); before(function () { if (typeof Proxy === "undefined" || typeof Reflect === "undefined" || chai.util.proxify === undefined) { /* eslint-disable no-invalid-this */ this.skip(); /* eslint-enable no-invalid-this */ } }); it("should guard against invalid property following `.should`", () => { shouldGuard(() => number.should.pizza, "pizza"); }); it("should guard against invalid property following overwritten language chain", () => { shouldGuard(() => number.should.to.pizza, "pizza"); }); it("should guard against invalid property following overwritten property assertion", () => { shouldGuard(() => number.should.ok.pizza, "pizza"); }); it("should guard against invalid property following uncalled overwritten method assertion", () => { shouldGuard(() => number.should.equal.pizza, "equal.pizza. See docs"); }); it("should guard against invalid property following called overwritten method assertion", () => { shouldGuard(() => number.should.equal(number).pizza, "pizza"); }); it("should guard against invalid property following uncalled overwritten chainable method assertion", () => { shouldGuard(() => number.should.a.pizza, "pizza"); }); it("should guard against invalid property following called overwritten chainable method assertion", () => { shouldGuard(() => number.should.a("number").pizza, "pizza"); }); it("should guard against invalid property following `.eventually`", () => { shouldGuard(() => promise.should.eventually.pizza, "pizza"); }); it("should guard against invalid property following `.fulfilled`", () => { shouldGuard(() => promise.should.fulfilled.pizza, "pizza"); }); it("should guard against invalid property following `.rejected`", () => { shouldGuard(() => promise.should.rejected.pizza, "pizza"); }); it("should guard against invalid property following called `.rejectedWith`", () => { shouldGuard(() => promise.should.rejectedWith(42).pizza, "pizza"); }); it("should guard against invalid property following uncalled `.rejectedWith`", () => { shouldGuard(() => promise.should.rejectedWith.pizza, "rejectedWith.pizza. See docs"); }); it("should guard against invalid property following called `.become`", () => { shouldGuard(() => promise.should.become(42).pizza, "pizza"); }); it("should guard against invalid property following uncalled `.become`", () => { shouldGuard(() => promise.should.become.pizza, "become.pizza. See docs"); }); }); chai-as-promised-7.1.1/test/should-eventually.js000066400000000000000000000217111312703150000216400ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const shouldPass = require("./support/common.js").shouldPass; const shouldFail = require("./support/common.js").shouldFail; describe("Fulfillment value assertions:", () => { let promise = null; describe("Direct tests of fulfilled promises:", () => { describe("Basics:", () => { it(".eventually.equal(42)", done => { Promise.resolve(42).should.eventually.equal(42).notify(done); }); it(".eventually.be.arguments", function (done) { Promise.resolve(arguments).should.eventually.be.arguments.notify(done); }); it(".eventually.be.empty", done => { Promise.resolve([]).should.eventually.be.empty.notify(done); }); it(".eventually.exist", done => { Promise.resolve(true).should.eventually.exist.notify(done); }); it(".eventually.be.false", done => { Promise.resolve(false).should.eventually.be.false.notify(done); }); it(".eventually.be.ok", done => { Promise.resolve({}).should.eventually.be.ok.notify(done); }); it(".eventually.be.true", done => { Promise.resolve(true).should.eventually.be.true.notify(done); }); it(".become(true)", done => { Promise.resolve(true).should.become(true).notify(done); }); }); describe("With flags and chainable methods involved:", () => { it(".not.eventually.be.ok", done => { Promise.resolve(false).should.not.eventually.be.ok.notify(done); }); it(".eventually.not.be.ok", done => { Promise.resolve(false).should.eventually.not.be.ok.notify(done); }); it(".eventually.deep.equal({ foo: 'bar' })", done => { Promise.resolve({ foo: "bar" }).should.eventually.deep.equal({ foo: "bar" }).notify(done); }); it(".not.eventually.deep.equal({ foo: 'bar' })", done => { Promise.resolve({ foo: "baz" }).should.not.eventually.deep.equal({ foo: "bar" }).notify(done); }); it(".eventually.not.deep.equal({ foo: 'bar' })", done => { Promise.resolve({ foo: "baz" }).should.eventually.not.deep.equal({ foo: "bar" }).notify(done); }); it(".eventually.contain('foo')", done => { Promise.resolve(["foo", "bar"]).should.eventually.contain("foo").notify(done); }); it(".not.eventually.contain('foo')", done => { Promise.resolve(["bar", "baz"]).should.not.eventually.contain("foo").notify(done); }); it(".eventually.not.contain('foo')", done => { Promise.resolve(["bar", "baz"]).should.eventually.not.contain("foo").notify(done); }); it(".eventually.contain.keys('foo')", done => { Promise.resolve({ foo: "bar", baz: "quux" }).should.eventually.contain.keys("foo").notify(done); }); it(".not.eventually.contain.keys('foo')", done => { Promise.resolve({ baz: "quux" }).should.not.eventually.contain.keys("foo").notify(done); }); it(".eventually.not.contain.keys('foo')", done => { Promise.resolve({ baz: "quux" }).should.eventually.not.contain.keys("foo").notify(done); }); it(".eventually.be.an.instanceOf(Array)", done => { Promise.resolve([]).should.eventually.be.an.instanceOf(Array).notify(done); }); if (Object.prototype.should.nested) { it(".eventually.have.nested.property('foo.bar')", done => { Promise.resolve({ foo: { bar: "baz" } }).should.eventually.have.nested.property("foo.bar", "baz") .notify(done); }); } }); }); describe("Chaining:", () => { it(".eventually.be.ok.and.equal(42)", done => { Promise.resolve(42).should.eventually.be.ok.and.equal(42).notify(done); }); it(".rejected.and.notify(done)", done => { Promise.reject().should.be.rejected.and.notify(done); }); it(".fulfilled.and.notify(done)", done => { Promise.resolve().should.be.fulfilled.and.notify(done); }); }); describe("On a promise fulfilled with the number 42:", () => { beforeEach(() => { promise = Promise.resolve(42); }); describe(".eventually.equal(42)", () => { shouldPass(() => promise.should.eventually.equal(42)); }); describe(".eventually.eql(42)", () => { shouldPass(() => promise.should.eventually.eql(42)); }); describe(".eventually.be.below(9000)", () => { shouldPass(() => promise.should.eventually.be.below(9000)); }); describe(".eventually.be.a('number')", () => { shouldPass(() => promise.should.eventually.be.a("number")); }); describe(".eventually.be.an.instanceOf(String)", () => { shouldFail({ op: () => promise.should.eventually.be.an.instanceOf(String), message: "42 to be an instance of String" }); }); describe(".eventually.be.false", () => { shouldFail({ op: () => promise.should.eventually.be.false, message: "to be false" }); }); describe(".eventually.be.an('object')", () => { shouldFail({ op: () => promise.should.eventually.be.an("object"), message: "to be an object" }); }); describe(".eventually.not.equal(52)", () => { shouldPass(() => promise.should.eventually.not.equal(52)); }); describe(".not.eventually.equal(52)", () => { shouldPass(() => promise.should.not.eventually.equal(52)); }); describe(".eventually.not.equal(42)", () => { shouldFail({ op: () => promise.should.eventually.not.equal(42), message: "not equal 42" }); }); describe(".not.eventually.equal(42)", () => { shouldFail({ op: () => promise.should.not.eventually.equal(42), message: "not equal 42" }); }); describe(".become(42)", () => { shouldPass(() => promise.should.become(42)); }); describe(".become(52)", () => { shouldFail({ op: () => promise.should.become(52), message: "deeply equal 52" }); }); describe(".not.become(42)", () => { shouldFail({ op: () => promise.should.not.become(42), message: "not deeply equal 42" }); }); describe(".not.become(52)", () => { shouldPass(() => promise.should.not.become(52)); }); }); describe("On a promise fulfilled with { foo: 'bar' }:", () => { beforeEach(() => { promise = Promise.resolve({ foo: "bar" }); }); describe(".eventually.equal({ foo: 'bar' })", () => { shouldFail({ op: () => promise.should.eventually.equal({ foo: "bar" }), message: "to equal { foo: 'bar' }" }); }); describe(".eventually.eql({ foo: 'bar' })", () => { shouldPass(() => promise.should.eventually.eql({ foo: "bar" })); }); describe(".eventually.deep.equal({ foo: 'bar' })", () => { shouldPass(() => promise.should.eventually.deep.equal({ foo: "bar" })); }); describe(".eventually.not.deep.equal({ foo: 'bar' })", () => { shouldFail({ op: () => promise.should.eventually.not.deep.equal({ foo: "bar" }), message: "not deeply equal { foo: 'bar' }" }); }); describe(".eventually.deep.equal({ baz: 'quux' })", () => { shouldFail({ op: () => promise.should.eventually.deep.equal({ baz: "quux" }), message: "deeply equal { baz: 'quux' }" }); }); describe(".eventually.not.deep.equal({ baz: 'quux' })", () => { shouldPass(() => promise.should.eventually.not.deep.equal({ baz: "quux" })); }); describe(".become({ foo: 'bar' })", () => { shouldPass(() => promise.should.become({ foo: "bar" })); }); describe(".not.become({ foo: 'bar' })", () => { shouldFail({ op: () => promise.should.not.become({ foo: "bar" }), message: "deeply equal { foo: 'bar' }" }); }); describe(".eventually.have.property('foo').that.equals('bar')", () => { shouldPass(() => promise.should.eventually.have.property("foo").that.equals("bar")); }); }); }); chai-as-promised-7.1.1/test/should-promise-specific.js000066400000000000000000000626321312703150000227200ustar00rootroot00000000000000"use strict"; require("./support/setup.js"); const shouldPass = require("./support/common.js").shouldPass; const shouldFail = require("./support/common.js").shouldFail; const expect = require("chai").expect; describe("Promise-specific extensions:", () => { let promise = null; const error = new Error("boo"); error.myProp = ["myProp value"]; const custom = "No. I am your father."; function assertingDoneFactory(done) { return result => { try { expect(result).to.equal(error); } catch (assertionError) { done(assertionError); } done(); }; } describe("when the promise is fulfilled", () => { beforeEach(() => { promise = Promise.resolve(42); }); describe(".fulfilled", () => { shouldPass(() => promise.should.be.fulfilled); }); describe(".fulfilled passes the fulfilled value", () => { shouldPass(() => promise.should.be.fulfilled.then(passedValue => { passedValue.should.equal(42); })); }); describe(".fulfilled allows chaining", () => { shouldPass(() => promise.should.be.fulfilled.and.eventually.equal(42)); }); describe(".not.fulfilled", () => { shouldFail({ op: () => promise.should.not.be.fulfilled, message: "not to be fulfilled but it was fulfilled with 42" }); }); describe(".rejected", () => { shouldFail({ op: () => promise.should.be.rejected, message: "to be rejected but it was fulfilled with 42" }); }); describe(".not.rejected passes the fulfilled value", () => { shouldPass(() => promise.should.not.be.rejected.then(passedValue => { passedValue.should.equal(42); })); }); // .not inverts all following assertions so the following test is // equivalent to promise.should.eventually.not.equal(31) describe(".not.rejected allows chaining", () => { shouldPass(() => promise.should.not.be.rejected.and.eventually.equal(31)); }); describe(".rejectedWith(TypeError)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError), message: "to be rejected with 'TypeError' but it was fulfilled with 42" }); }); describe(".not.rejectedWith(TypeError) passes the fulfilled value", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError).then(passedValue => { passedValue.should.equal(42); })); }); describe(".not.rejectedWith(TypeError) allows chaining", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError).and.eventually.equal(31)); }); describe(".rejectedWith('message substring')", () => { shouldFail({ op: () => promise.should.be.rejectedWith("message substring"), message: "to be rejected with an error including 'message substring' but it was fulfilled with " + "42" }); }); describe(".rejectedWith(/regexp/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(/regexp/), message: "to be rejected with an error matching /regexp/ but it was fulfilled with 42" }); }); describe(".rejectedWith(TypeError, 'message substring')", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, "message substring"), message: "to be rejected with 'TypeError' but it was fulfilled with 42" }); }); describe(".rejectedWith(TypeError, /regexp/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, /regexp/), message: "to be rejected with 'TypeError' but it was fulfilled with 42" }); }); describe(".rejectedWith(errorInstance)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(error), message: "to be rejected with 'Error: boo' but it was fulfilled with 42" }); }); describe(".not.rejected", () => { shouldPass(() => promise.should.not.be.rejected); }); describe(".not.rejectedWith(TypeError)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError)); }); describe(".not.rejectedWith('message substring')", () => { shouldPass(() => promise.should.not.be.rejectedWith("message substring")); }); describe(".not.rejectedWith(/regexp/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(/regexp/)); }); describe(".not.rejectedWith(TypeError, 'message substring')", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, "message substring")); }); describe(".not.rejectedWith(TypeError, /regexp/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, /regexp/)); }); describe(".not.rejectedWith(errorInstance)", () => { shouldPass(() => promise.should.not.be.rejectedWith(error)); }); describe(".should.notify(done)", () => { it("should pass the test", done => { promise.should.notify(done); }); }); }); describe("when the promise is rejected", () => { beforeEach(() => { promise = Promise.reject(error); }); describe(".fulfilled", () => { shouldFail({ op: () => promise.should.be.fulfilled, message: "to be fulfilled but it was rejected with 'Error: boo'" }); }); describe(".not.fulfilled", () => { shouldPass(() => promise.should.not.be.fulfilled); }); describe(".not.fulfilled should allow chaining", () => { shouldPass(() => promise.should.not.be.fulfilled.and.eventually.have.property("nonexistent")); }); describe(".not.fulfilled should pass the rejection reason", () => { shouldPass(() => promise.should.not.be.fulfilled.then(passedError => { passedError.should.equal(error); })); }); describe(".rejected", () => { shouldPass(() => promise.should.be.rejected); }); describe(".not.rejected", () => { shouldFail({ op: () => promise.should.not.be.rejected, message: "not to be rejected but it was rejected with 'Error: boo'" }); }); describe(".rejected should allow chaining", () => { shouldPass(() => promise.should.be.rejected.and.eventually.have.property("myProp")); }); describe(".rejected passes the rejection reason", () => { shouldPass(() => promise.should.be.rejected.then(passedError => { passedError.should.equal(error); })); }); describe(".rejectedWith(theError)", () => { shouldPass(() => promise.should.be.rejectedWith(error)); }); describe(".not.rejectedWith(theError)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(error), message: "not to be rejected with 'Error: boo'" }); }); describe(".rejectedWith(theError) should allow chaining", () => { shouldPass(() => promise.should.be.rejectedWith(error).and.eventually.have.property("myProp")); }); describe(".rejectedWith(theError) passes the rejection reason", () => { shouldPass(() => promise.should.be.rejectedWith(error).then(passedError => { passedError.should.equal(error); })); }); describe(".rejectedWith(differentError)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(new Error()), message: "to be rejected with 'Error' but it was rejected with 'Error: boo'" }); }); describe(".not.rejectedWith(differentError)", () => { shouldPass(() => promise.should.not.be.rejectedWith(new Error())); }); // Chai 3.5.0 never interprets the 2nd paramter to // expect(fn).to.throw(a, b) as a custom error message. This is // what we are testing here. describe(".rejectedWith(differentError, custom)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(new Error(), custom), message: "to be rejected with 'Error' but it was rejected with 'Error: boo'", notMessage: custom }); }); describe(".not.rejectedWith(differentError, custom)", () => { shouldPass(() => promise.should.not.be.rejectedWith(new Error(), custom)); }); describe("with an Error having message 'foo bar'", () => { beforeEach(() => { promise = Promise.reject(new Error("foo bar")); }); describe(".rejectedWith('foo')", () => { shouldPass(() => promise.should.be.rejectedWith("foo")); }); describe(".not.rejectedWith('foo')", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith("foo"), message: "not to be rejected with an error including 'foo'" }); }); describe(".rejectedWith(/bar/)", () => { shouldPass(() => promise.should.be.rejectedWith(/bar/)); }); describe(".not.rejectedWith(/bar/)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(/bar/), message: "not to be rejected with an error matching /bar/" }); }); describe(".rejectedWith('quux')", () => { shouldFail({ op: () => promise.should.be.rejectedWith("quux"), message: "to be rejected with an error including 'quux' but got 'foo bar'" }); }); describe(".not.rejectedWith('quux')", () => { shouldPass(() => promise.should.be.not.rejectedWith("quux")); }); describe(".rejectedWith(/quux/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(/quux/), message: "to be rejected with an error matching /quux/ but got 'foo bar'" }); }); describe(".not.rejectedWith(/quux/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(/quux/)); }); // Chai 3.5.0 never interprets the 2nd paramter to // expect(fn).to.throw(a, b) as a custom error // message. This is what we are testing here. describe(".rejectedWith('foo', custom)", () => { shouldPass(() => promise.should.be.rejectedWith("foo", custom)); }); describe(".not.rejectedWith('foo', custom)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith("foo", custom), message: "not to be rejected with an error including 'foo'", notMessage: custom }); }); describe(".rejectedWith(/bar/, custom)", () => { shouldPass(() => promise.should.be.rejectedWith(/bar/, custom)); }); describe(".not.rejectedWith(/bar/, custom)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(/bar/), message: "not to be rejected with an error matching /bar/", notMessage: custom }); }); }); describe("with a RangeError", () => { beforeEach(() => { promise = Promise.reject(new RangeError()); }); describe(".rejectedWith(RangeError)", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError)); }); describe(".not.rejectedWith(RangeError)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError), message: "not to be rejected with 'RangeError' but it was rejected with 'RangeError'" }); }); describe(".rejectedWith(TypeError)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError'" }); }); // Case for issue #64. describe(".rejectedWith(Array)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(Array), message: "to be rejected with 'Array' but it was rejected with 'RangeError'" }); }); describe(".not.rejectedWith(TypeError)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError)); }); }); describe("with a RangeError having a message 'foo bar'", () => { beforeEach(() => { promise = Promise.reject(new RangeError("foo bar")); }); describe(".rejectedWith(RangeError, 'foo')", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError, "foo")); }); describe(".not.rejectedWith(RangeError, 'foo')", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, "foo"), message: "not to be rejected with 'RangeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".rejectedWith(RangeError, /bar/)", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError, /bar/)); }); describe(".not.rejectedWith(RangeError, /bar/)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, /bar/), message: "not to be rejected with 'RangeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".rejectedWith(RangeError, 'quux')", () => { shouldFail({ op: () => promise.should.be.rejectedWith(RangeError, "quux"), message: "to be rejected with an error including 'quux' but got 'foo bar'" }); }); describe(".rejectedWith(RangeError, /quux/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(RangeError, /quux/), message: "to be rejected with an error matching /quux/ but got 'foo bar'" }); }); describe(".rejectedWith(TypeError, 'foo')", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, "foo"), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".rejectedWith(TypeError, /bar/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, /bar/), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".rejectedWith(TypeError, 'quux')", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, "quux"), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".rejectedWith(TypeError, /quux/)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, /quux/), message: "to be rejected with 'TypeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".not.rejectedWith(RangeError, 'foo')", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, "foo"), message: "not to be rejected with 'RangeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".not.rejectedWith(RangeError, /bar/)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, /bar/), message: "not to be rejected with 'RangeError' but it was rejected with 'RangeError: foo bar'" }); }); describe(".not.rejectedWith(RangeError, 'quux')", () => { shouldPass(() => promise.should.not.be.rejectedWith(RangeError, "quux")); }); describe(".not.rejectedWith(RangeError, /quux/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(RangeError, /quux/)); }); describe(".not.rejectedWith(TypeError, 'foo')", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, "foo")); }); describe(".not.rejectedWith(TypeError, /bar/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, /bar/)); }); describe(".not.rejectedWith(TypeError, 'quux')", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, "quux")); }); describe(".not.rejectedWith(TypeError, /quux/)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, /quux/)); }); describe(".rejectedWith(RangeError, 'foo', custom)", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError, "foo", custom)); }); describe(".not.rejectedWith(RangeError, 'foo', custom)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, "foo", custom), message: custom }); }); describe(".rejectedWith(RangeError, /bar/, custom)", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError, /bar/, custom)); }); describe(".not.rejectedWith(RangeError, /bar/, custom)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, /bar/, custom), message: custom }); }); describe(".rejectedWith(RangeError, 'quux', custom)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(RangeError, "quux", custom), message: custom }); }); describe(".not.rejectedWith(TypeError, 'quux', custom)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, "quux", custom)); }); describe(".rejectedWith(RangeError, /quux/, custom)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(RangeError, /quux/, custom), message: custom }); }); describe(".not.rejectedWith(TypeError, /quux/, custom)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, /quux/, custom)); }); describe(".rejectedWith(RangeError, undefined, custom)", () => { shouldPass(() => promise.should.be.rejectedWith(RangeError, undefined, custom)); }); describe(".not.rejectedWith(RangeError, undefined, custom)", () => { shouldFail({ op: () => promise.should.not.be.rejectedWith(RangeError, undefined, custom), message: custom }); }); describe(".rejectedWith(TypeError, undefined, custom)", () => { shouldFail({ op: () => promise.should.be.rejectedWith(TypeError, undefined, custom), message: custom }); }); describe(".not.rejectedWith(TypeError, undefined, custom)", () => { shouldPass(() => promise.should.not.be.rejectedWith(TypeError, undefined, custom)); }); }); describe(".should.notify(done)", () => { it("should fail the test with the original error", done => { promise.should.notify(assertingDoneFactory(done)); }); }); }); describe(".should.notify with chaining (GH-3)", () => { describe("the original promise is fulfilled", () => { beforeEach(() => { promise = Promise.resolve(); }); describe("and the follow-up promise is fulfilled", () => { beforeEach(() => { promise = promise.then(() => { /* Do nothing */ }); }); it("should pass the test", done => { promise.should.notify(done); }); }); describe("but the follow-up promise is rejected", () => { beforeEach(() => { promise = promise.then(() => { throw error; }); }); it("should fail the test with the error from the follow-up promise", done => { promise.should.notify(assertingDoneFactory(done)); }); }); }); describe("the original promise is rejected", () => { beforeEach(() => { promise = Promise.reject(error); }); describe("but the follow-up promise is fulfilled", () => { beforeEach(() => { promise = promise.then(() => { /* Do nothing */ }); }); it("should fail the test with the error from the original promise", done => { promise.should.notify(assertingDoneFactory(done)); }); }); describe("and the follow-up promise is rejected", () => { beforeEach(() => { promise = promise.then(() => { throw new Error("follow up"); }); }); it("should fail the test with the error from the original promise", done => { promise.should.notify(assertingDoneFactory(done)); }); }); }); }); describe("Using with non-thenables", () => { describe("A number", () => { const number = 5; it("should fail for .fulfilled", () => { expect(() => number.should.be.fulfilled).to.throw(TypeError, "not a thenable"); }); it("should fail for .rejected", () => { expect(() => number.should.be.rejected).to.throw(TypeError, "not a thenable"); }); it("should fail for .become", () => { expect(() => number.should.become(5)).to.throw(TypeError, "not a thenable"); }); it("should fail for .eventually", () => { expect(() => number.should.eventually.equal(5)).to.throw(TypeError, "not a thenable"); }); it("should fail for .notify", () => { expect(() => number.should.notify(() => { /* Doesn't matter */ })) .to.throw(TypeError, "not a thenable"); }); }); }); describe("Using together with other Chai as Promised asserters", () => { describe(".fulfilled.and.eventually.equal(42)", () => { shouldPass(() => Promise.resolve(42).should.be.fulfilled.and.eventually.equal(42)); }); describe(".fulfilled.and.rejected", () => { shouldFail({ op: () => Promise.resolve(42).should.be.fulfilled.and.rejected, message: "to be rejected but it was fulfilled with 42" }); }); describe(".rejected.and.eventually.equal(42)", () => { shouldPass(() => Promise.reject(42).should.be.rejected.and.eventually.equal(42)); }); describe(".rejected.and.become(42)", () => { shouldPass(() => Promise.reject(42).should.be.rejected.and.become(42)); }); }); describe("With promises that only become rejected later (GH-24)", () => { it("should wait for them", done => { let reject; const rejectedLaterPromise = new Promise((_, r) => { reject = r; }); rejectedLaterPromise.should.be.rejectedWith("error message").and.notify(done); setTimeout(() => reject(new Error("error message")), 100); }); }); describe("`rejectedWith` with non-`Error` rejection reasons (GH-33)", () => { shouldPass(() => Promise.reject(42).should.be.rejectedWith(42)); }); }); chai-as-promised-7.1.1/test/support/000077500000000000000000000000001312703150000173305ustar00rootroot00000000000000chai-as-promised-7.1.1/test/support/common.js000066400000000000000000000033731312703150000211640ustar00rootroot00000000000000"use strict"; exports.shouldPass = promiseProducer => { it("should return a fulfilled promise", done => { promiseProducer().then( () => done(), reason => done(new Error(`Expected promise to be fulfilled but it was rejected with ${reason.stack}`)) ); }); }; exports.shouldFail = options => { const promiseProducer = options.op; const desiredMessageSubstring = options.message; const nonDesiredMessageSubstring = options.notMessage; it("should return a promise rejected with an assertion error", done => { promiseProducer().then( () => { throw new Error("Expected promise to be rejected with an assertion error, but it was fulfilled"); }, reason => { if (Object(reason) !== reason || reason.constructor.name !== "AssertionError") { throw new Error(`Expected promise to be rejected with an AssertionError but it was rejected ` + `with ${reason}`); } if (desiredMessageSubstring && !reason.message.includes(desiredMessageSubstring)) { throw new Error(`Expected promise to be rejected with an AssertionError containing ` + `"${desiredMessageSubstring}" but it was rejected with ${reason}`); } if (nonDesiredMessageSubstring && reason.message.includes(nonDesiredMessageSubstring)) { throw new Error(`Expected promise to be rejected with an AssertionError not containing ` + `"${nonDesiredMessageSubstring}" but it was rejected with ${reason}`); } } ).then(done, done); }); }; chai-as-promised-7.1.1/test/support/setup.js000066400000000000000000000004661312703150000210340ustar00rootroot00000000000000"use strict"; const chai = require("chai"); const chaiAsPromised = require("../.."); chai.should(); chai.use(chaiAsPromised); process.on("unhandledRejection", () => { // Do nothing; we test these all the time. }); process.on("rejectionHandled", () => { // Do nothing; we test these all the time. });