stub-promise-function
Advanced tools
Comparing version 1.0.3 to 2.0.1
'use strict'; | ||
var Q = require('q'); | ||
var sinon = require('sinon'); | ||
@@ -7,6 +8,8 @@ module.exports = function() { | ||
var func = function() { | ||
return deferred.promise; | ||
}; | ||
// var func = function() { | ||
// return deferred.promise; | ||
// }; | ||
var func = sinon.stub().returns(deferred.promise); | ||
func.resolve = function(value) { | ||
@@ -13,0 +16,0 @@ deferred.resolve(value); |
{ | ||
"name": "stub-promise-function", | ||
"version": "1.0.3", | ||
"version": "2.0.1", | ||
"description": "A test utility that lets you stub and control promises for testing purposes", | ||
@@ -20,3 +20,4 @@ "repository": "https://github.com/jonbern/stub-promise-function.git", | ||
"dependencies": { | ||
"q": "^1.4.1" | ||
"q": "^1.4.1", | ||
"sinon": "^1.17.3" | ||
}, | ||
@@ -23,0 +24,0 @@ "devDependencies": { |
@@ -59,8 +59,4 @@ # stub-promise-function | ||
```javascript | ||
var expect = require('expectations'); | ||
var sinon = require('sinon'); | ||
var stubPromiseFunction = require('stub-promise-function'); | ||
describe('#stubPromiseFunction()', function() { | ||
describe('stubPromiseFunction', function() { | ||
var http; | ||
@@ -71,3 +67,3 @@ var promise; | ||
http = { | ||
get: stubPromiseFunction() | ||
get: stubPromise() | ||
}; | ||
@@ -130,8 +126,4 @@ }); | ||
describe('test spy example', function() { | ||
describe('spy functionality (using sinon.spy internally)', function() { | ||
beforeEach(function() { | ||
sinon.spy(http, 'get'); | ||
}); | ||
beforeEach(function simulateApi() { | ||
@@ -148,3 +140,3 @@ http.get('http://whatever'); | ||
describe('multiple invocation by re-instantiation example', function() { | ||
describe('multiple invocation by re-instantiation', function() { | ||
@@ -156,3 +148,3 @@ var http; | ||
http = { | ||
get: stubPromiseFunction() | ||
get: stubPromise() | ||
}; | ||
@@ -173,3 +165,3 @@ | ||
it('can be reinstantiated and then resolved', function() { | ||
http.get = stubPromiseFunction(); | ||
http.get = stubPromise(); | ||
@@ -176,0 +168,0 @@ promise = http.get('http://another'); |
10
tests.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
describe('stubPromise', function() { | ||
describe('#stubPromiseFunction()', function() { | ||
@@ -72,8 +72,4 @@ var http; | ||
describe('test spy example', function() { | ||
describe('spy functionality (using sinon.spy internally)', function() { | ||
beforeEach(function() { | ||
sinon.spy(http, 'get'); | ||
}); | ||
beforeEach(function simulateApi() { | ||
@@ -90,3 +86,3 @@ http.get('http://whatever'); | ||
describe('multiple invocation by re-instantiation example', function() { | ||
describe('multiple invocation by re-instantiation', function() { | ||
@@ -93,0 +89,0 @@ var http; |
8968
2
133
178
+ Addedsinon@^1.17.3
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfor-each@0.3.5(transitive)
+ Addedformatio@1.1.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedlolex@1.3.2(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedpossible-typed-array-names@1.1.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedsamsam@1.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsinon@1.17.7(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)