mock-promises
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,5 +0,11 @@ | ||
(function() { | ||
var exports = Function('return this')() || (1, eval)('this'); | ||
var extend = function(destination, source) { | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); | ||
} else { | ||
root.mockPromises = factory(); | ||
} | ||
}(this, function () { | ||
var extend = function(destination, source) { | ||
for(var property in source) { | ||
@@ -330,5 +336,3 @@ destination[property] = source[property]; | ||
exports.mockPromises = new MockPromises(); | ||
return exports.mockPromises; | ||
}).call(this); | ||
return new MockPromises(); | ||
})); |
{ | ||
"name": "mock-promises", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Charles Hansen <chansen87@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,3 +5,3 @@ #Mock Promises | ||
##Supported Libraries | ||
Mock Promises currently supports the [Q] promise library and native Promises (only for simple uses) in Chrome. If you would like to use Mock Promises for a library that is not supported, please open a github issue. | ||
Mock Promises currently supports the [Q] promise library, [es6-promise] libary (but not the `all` function), and native Promises (only for simple uses) in Chrome. If you would like to use Mock Promises for a library that is not supported, please open a github issue. | ||
@@ -20,16 +20,22 @@ Mock Promises is test framework agnostic, and we have code examples for the [jasmine] and [mocha] testing frameworks in the [spec/javascripts] directory. | ||
Node does not currently support native promises and you may need to use the [es6 promise polyfill] if you want to run the example specs. | ||
Node does not currently support native promises and you may need to use [es6-promise] if you want to run the example specs. | ||
## Q | ||
## Promise Libraries | ||
#### Setup | ||
(These directions are for the Q library, or any libraries with a similar re-use of the `then` function.) | ||
To start mocking, use the `install` function. The argument to `install` is the `Promise` class used by your promise library. It happens to be `Q.makePromise` for Q. | ||
To start mocking, use the `install` function. The argument to `install` is the `Promise` class used by your promise library. | ||
- Q | ||
```js | ||
mockPromises.install(Q.makePromise) | ||
``` | ||
- ES6-Promise | ||
```js | ||
mockPromises.install(ES6Promise.Promise) | ||
``` | ||
- Other Libraries | ||
It is recommended to put this is in the global `beforeEach` of your spec helper. Any promises that are instantiated before you start mocking will not be mocked. | ||
In principal, mock promises can be used with any testing library that mostly uses `then` under the hood. It does rely a bit on internal state, so each library probably needs a small amount of work to use (or a large amount for native promises). | ||
It is recommended to put the `install` is in the global `beforeEach` of your spec helper. Any promises that are instantiated before you start mocking will not be mocked. | ||
To prevent test pollution, you should reset mocking between tests | ||
@@ -170,3 +176,3 @@ ```js | ||
[RSVP]:https://github.com/tildeio/rsvp.js/ | ||
[es6 promise polyfill]:https://github.com/jakearchibald/es6-promise | ||
[es6-promise]:https://github.com/jakearchibald/es6-promise | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18987
296
176