testdouble
Advanced tools
Comparing version 1.7.0 to 1.8.0
# Change Log | ||
## [v1.8.0](https://github.com/testdouble/testdouble.js/tree/v1.8.0) (2016-10-12) | ||
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.7.0...v1.8.0) | ||
**Closed issues:** | ||
- Feature request: Partial object matchers [\#141](https://github.com/testdouble/testdouble.js/issues/141) | ||
- Drop CoffeeScript [\#140](https://github.com/testdouble/testdouble.js/issues/140) | ||
- Question with verifications [\#138](https://github.com/testdouble/testdouble.js/issues/138) | ||
- td.reset\(\) it´s working has expected? [\#133](https://github.com/testdouble/testdouble.js/issues/133) | ||
**Merged pull requests:** | ||
- Docs for multiple captor values. [\#145](https://github.com/testdouble/testdouble.js/pull/145) ([marchaos](https://github.com/marchaos)) | ||
- Allow for multiple captor invocations [\#144](https://github.com/testdouble/testdouble.js/pull/144) ([marchaos](https://github.com/marchaos)) | ||
- Remove warning of implementations of ES2015 proxy [\#136](https://github.com/testdouble/testdouble.js/pull/136) ([mgryszko](https://github.com/mgryszko)) | ||
- Fix shorthand notation for stubbing [\#135](https://github.com/testdouble/testdouble.js/pull/135) ([mgryszko](https://github.com/mgryszko)) | ||
## [v1.7.0](https://github.com/testdouble/testdouble.js/tree/v1.7.0) (2016-09-18) | ||
@@ -4,0 +21,0 @@ [Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.6.2...v1.7.0) |
@@ -98,4 +98,2 @@ # Creating Test Doubles | ||
> **Warning [2015-11-22]:** This feature is currently only supported on a handful of JavaScript runtimes, most notably FireFox and Microsoft Edge. | ||
If passed either a string name or no arguments at all, `td.object` will return an [ES2015 Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) object designed to forward any property access as if it was a test double function. By using `Proxy`, testdouble.js is able to intercept calls to properties that don't exist, immediately create a new test double function, and invoke that function for use in either stubbing or verifying behavior. | ||
@@ -102,0 +100,0 @@ |
@@ -74,3 +74,3 @@ # Stubbing behavior | ||
``` javascript | ||
var woof = td.when(td.function()).thenReturn('bark') | ||
var woof = td.when(td.function()()).thenReturn('bark') | ||
``` | ||
@@ -77,0 +77,0 @@ |
@@ -298,2 +298,21 @@ # Verifying interactions | ||
#### Capturing multiple invocations with td.matchers.captor() | ||
In some cases you may want to capture multiple invocations of the same function or | ||
method in one test. A common usecase for this is subscription based APIs where a | ||
callback will be invoked for each message. To handle this usecase, `captors` expose | ||
a `values` array which will hold each argument passed during every invocation of the | ||
callback: | ||
``` javascript | ||
var captor = td.matchers.captor(), | ||
responseCallback = td.function(); | ||
subscribe('/chat', responseCallback); // subscribe() will call responseCallback twice | ||
td.verify(responseCallback('/chat', captor.capture())) | ||
assert.equal(captor.values[0], 'first message'); | ||
assert.equal(captor.values[1], 'second message'); | ||
```` | ||
### Configuring verifications | ||
@@ -300,0 +319,0 @@ |
@@ -24,3 +24,3 @@ // Generated by CoffeeScript 1.10.0 | ||
}); | ||
return describe('when verifying', function() { | ||
describe('when verifying', function() { | ||
Given(function() { | ||
@@ -32,8 +32,28 @@ return this.testDouble("SHIRTS!"); | ||
}); | ||
return Then(function() { | ||
Then(function() { | ||
return this.captor.value === "SHIRTS!"; | ||
}); | ||
return And(function() { | ||
return expect(this.captor.values).to.deep.eq(["SHIRTS!"]); | ||
}); | ||
}); | ||
return describe('when verifying multiple', function() { | ||
Given(function() { | ||
return this.testDouble("SHIRTS!"); | ||
}); | ||
And(function() { | ||
return this.testDouble("SHIRTS AGAIN!"); | ||
}); | ||
When(function() { | ||
return td.verify(this.testDouble(this.captor.capture())); | ||
}); | ||
Then(function() { | ||
return this.captor.value === "SHIRTS AGAIN!"; | ||
}); | ||
return And(function() { | ||
return expect(this.captor.values).to.deep.eq(["SHIRTS!", "SHIRTS AGAIN!"]); | ||
}); | ||
}); | ||
}); | ||
}).call(this); |
@@ -13,2 +13,4 @@ // Generated by CoffeeScript 1.10.0 | ||
matches: function(matcherArgs, actual) { | ||
captor.values || (captor.values = []); | ||
captor.values.push(actual); | ||
captor.value = actual; | ||
@@ -15,0 +17,0 @@ return true; |
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
module.exports = '1.7.0'; | ||
module.exports = '1.8.0'; | ||
}).call(this); |
{ | ||
"name": "testdouble", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "A minimal test double library for TDD with JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/testdouble/testdouble.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
558091
11146