@sinonjs/referee
Advanced tools
Comparing version 6.1.0 to 6.2.0
# Changes | ||
## 6.2.0 | ||
- [`0e9ab9b`](https://github.com/sinonjs/referee/commit/0e9ab9b4b5663ea22dc01c5de0fa385a118ee2c8) | ||
Adjust documentation for resolves and rejects (Maximilian Antoni) | ||
- [`fe4616e`](https://github.com/sinonjs/referee/commit/fe4616e8961efa2c0af1d07a27dba9a6036caff7) | ||
Support resolves and rejects without expectation (Maximilian Antoni) | ||
- [`4b21019`](https://github.com/sinonjs/referee/commit/4b210199fadfbb95c283fac131bb67c2e2e8edf6) | ||
Use deepEqual to compare rejected promise value (Maximilian Antoni) | ||
- [`b001fed`](https://github.com/sinonjs/referee/commit/b001fed44fdb5e8d454c90d40e98848f4eb4739b) | ||
Use deepEqual to compare resolved promise value (Maximilian Antoni) | ||
_Released by [Maximilian Antoni](https://github.com/mantoni) on 2020-11-07._ | ||
## 6.1.0 | ||
@@ -4,0 +17,0 @@ |
@@ -1484,3 +1484,3 @@ # referee | ||
```js | ||
assert.resolves(promise, value) | ||
assert.resolves(promise[, value]) | ||
``` | ||
@@ -1491,8 +1491,8 @@ | ||
The assertion **resolves**, if the value resolved from `promise` is | ||
[`identical`](http://sinonjs.github.io/samsam/#identicalx-y) to the given `value`. | ||
The assertion **resolves**, if the value resolved from `promise` | ||
[`equals`](#equals) the given `value`. | ||
Furthermore, the assertion **rejects** if, | ||
* the resolved value from the input `promise` is not `identical` to the given `value` | ||
* the resolved value from the input `promise` is not equal to the given `value` | ||
* the given `promise` rejects instead of resolving | ||
@@ -1521,3 +1521,3 @@ * the given input is not a Promise | ||
```js | ||
assert.rejects(promise, value) | ||
assert.rejects(promise[, value]) | ||
``` | ||
@@ -1528,8 +1528,8 @@ | ||
The assertion **resolves**, if the value rejected from `promise` is | ||
[`identical`](http://sinonjs.github.io/samsam/#identicalx-y) to the given `value`. | ||
The assertion **resolves**, if the value rejected from `promise` | ||
[`equals`](#equals) the given `value`. | ||
Furthermore, the assertion **rejects** if, | ||
* the rejected value from the input `promise` is not `identical` to the given `value` | ||
* the rejected value from the input `promise` is not equal to the given `value` | ||
* the given `promise` resolves instead of rejecting | ||
@@ -1536,0 +1536,0 @@ * the given input is not a Promise |
@@ -6,4 +6,4 @@ "use strict"; | ||
var assertMessage = "${actual} is not identical to ${expected}"; | ||
var refuteMessage = "${actual} is identical to ${expected}"; | ||
var assertMessage = "${actual} is not equal to ${expected}"; | ||
var refuteMessage = "${actual} is equal to ${expected}"; | ||
@@ -16,3 +16,3 @@ module.exports = function(referee) { | ||
assert: createAsyncAssertion(thenCallback, function(actual, expected) { | ||
if (!samsam.identical(actual, expected)) { | ||
if (!samsam.deepEqual(actual, expected)) { | ||
this.reject(assertMessage); | ||
@@ -24,4 +24,8 @@ return; | ||
refute: createAsyncAssertion(thenCallback, function(actual, expected) { | ||
if (samsam.identical(actual, expected)) { | ||
this.reject(refuteMessage); | ||
if (samsam.deepEqual(actual, expected)) { | ||
if (expected === samsam.match.any) { | ||
this.reject("${0} rejected unexpectedly"); | ||
} else { | ||
this.reject(refuteMessage); | ||
} | ||
return; | ||
@@ -28,0 +32,0 @@ } |
@@ -6,4 +6,4 @@ "use strict"; | ||
var assertMessage = "${actual} is not identical to ${expected}"; | ||
var refuteMessage = "${actual} is identical to ${expected}"; | ||
var assertMessage = "${actual} is not equal to ${expected}"; | ||
var refuteMessage = "${actual} is equal to ${expected}"; | ||
@@ -16,3 +16,3 @@ module.exports = function(referee) { | ||
assert: createAsyncAssertion(function(actual, expected) { | ||
if (!samsam.identical(actual, expected)) { | ||
if (!samsam.deepEqual(actual, expected)) { | ||
this.reject(assertMessage); | ||
@@ -24,4 +24,8 @@ return; | ||
refute: createAsyncAssertion(function(actual, expected) { | ||
if (samsam.identical(actual, expected)) { | ||
this.reject(refuteMessage); | ||
if (samsam.deepEqual(actual, expected)) { | ||
if (expected === samsam.match.any) { | ||
this.reject("${0} resolved unexpectedly"); | ||
} else { | ||
this.reject(refuteMessage); | ||
} | ||
return; | ||
@@ -28,0 +32,0 @@ } |
"use strict"; | ||
var samsam = require("@sinonjs/samsam"); | ||
function createAsyncAssertion(thenFunc, catchFunc) { | ||
function asyncAssertion(promise, expected) { | ||
var self = this; | ||
this.expected = expected; | ||
this.expected = arguments.length === 1 ? samsam.match.any : expected; | ||
function applyCallback(callback, context) { | ||
return function(actual) { | ||
self.actual = actual; | ||
callback.apply(context, [actual, expected]); | ||
callback.apply(context, [actual, self.expected]); | ||
}; | ||
@@ -12,0 +14,0 @@ } |
{ | ||
"name": "@sinonjs/referee", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Assertions for any JavaScript test framework and environment", | ||
@@ -5,0 +5,0 @@ "author": "Christian Johansen", |
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
139205
1714