🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

chai-changes

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-changes - npm Package Compare versions

Comparing version

to
1.2.0

5

chai-changes.js

@@ -65,6 +65,3 @@ // Generated by CoffeeScript 1.3.2

newPromise = result.then(promiseCallback, promiseCallback);
if (newPromise != null ? newPromise.then : void 0) {
this.then = newPromise.then;
}
flag(this, 'object', newPromise);
return newPromise;
} else {

@@ -71,0 +68,0 @@ for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {

2

package.json

@@ -6,3 +6,3 @@ {

"keywords": [ "test", "assertion", "assert", "testing", "changes", "promises" ],
"version": "1.1.1",
"version": "1.2.0",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

@@ -40,12 +40,30 @@ chai-changes

#### Promises
When the callback returns a promise, the post-conditions are executed
when the promise is fulfilled.
Since the 'object' in the assertion chain is changed after the when, you
can chain [chai-as-promised](https://github.com/domenic/chai-as-promised) matchers too, like:
`(-> result).should.change.to(4).when(-> object.methodThatReturnsPromise()).and.notify(done)`
The `when` statement will return an assertion promise when the result of
the `when` block is a promise. To use in mocha, you can specify an
`notify` key to trigger `done()`
This makes this mechanism also compatible with
[mocha-as-promised](https://github.com/domenic/mocha-as-promised)
```coffeescript
expect(-> value).to.change.when(
-> promise
notify: done
)
```
if you use
[mocha-as-promised](https://github.com/domenic/mocha-as-promised), you
don't need to specify this notify method
an alternative would be:
```coffeescript
expect(-> value).to.change.when(-> promise).then
-> done()
(error) -> done(error)
```
### `change`

@@ -52,0 +70,0 @@

@@ -9,1 +9,4 @@ var chai = require("chai");

global.expect = require("chai").expect;
global.when = require("when");

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