chai-changes
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
// Generated by CoffeeScript 1.3.2 | ||
(function() { | ||
@@ -40,3 +40,3 @@ | ||
result = val(); | ||
isPromise = typeof result.then === 'function'; | ||
isPromise = (typeof result === 'object') && (typeof result.then === 'function'); | ||
if (((typeof DS !== "undefined" && DS !== null ? DS.Model : void 0) != null) && result instanceof DS.Model) { | ||
@@ -66,4 +66,6 @@ isPromise = false; | ||
newPromise = result.then(promiseCallback, promiseCallback); | ||
if (newPromise != null ? newPromise.then : void 0) { | ||
this.then = newPromise.then; | ||
} | ||
flag(this, 'object', newPromise); | ||
this.then = newPromise.then; | ||
} else { | ||
@@ -70,0 +72,0 @@ for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) { |
@@ -6,3 +6,3 @@ { | ||
"keywords": [ "test", "assertion", "assert", "testing", "changes", "promises" ], | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"repository": { | ||
@@ -18,7 +18,9 @@ "type": "git", | ||
"chai-as-promised": ">= 3.2.3", | ||
"coffee-script": ">= 1.4.0", | ||
"chai": ">= 1.0.0", | ||
"when": "*", | ||
"mocha": ">= 1.0.0" | ||
}, | ||
"scripts": { | ||
"test": "./test.sh" | ||
"test": "mocha" | ||
}, | ||
@@ -25,0 +27,0 @@ "licenses": [ |
104
README.md
chai-changes | ||
============ | ||
[![Build Status](https://travis-ci.org/matthijsgroen/chai-changes.png?branch=master)](https://travis-ci.org/matthijsgroen/chai-changes) | ||
chai-changes is an extension to the [chai](http://chaijs.com/) assertion library that | ||
provides a set of change-specific assertions. | ||
Usage | ||
----- | ||
Include `chai-changes.js` in your test file, after `chai.js` (version 1.0.0-rc1 or later): | ||
<script src="chai-changes.js"></script> | ||
Use the assertions with chai's `expect` or `should` assertions. | ||
Assertions | ||
@@ -21,7 +14,8 @@ ---------- | ||
Using 'expect': | ||
expect(-> codeThatYieldsAChangedResult).to....when -> | ||
executeTheCodeThatCausesTheChange() | ||
```coffeescript | ||
expect(-> codeThatYieldsAChangedResult).to....when -> | ||
executeTheCodeThatCausesTheChange() | ||
``` | ||
@@ -35,4 +29,6 @@ The code within the `expect` section will be executed first, then the | ||
(-> codeThatYieldsAChangedResult).should....when -> | ||
executeTheCodeThatCausesTheChange() | ||
```coffeescript | ||
(-> codeThatYieldsAChangedResult).should....when -> | ||
executeTheCodeThatCausesTheChange() | ||
``` | ||
@@ -61,6 +57,8 @@ ### when | ||
result = 0 | ||
(-> result).should.change.when -> result += 1 | ||
expect(-> result).to.change.when -> result -= 1 | ||
expect(-> result).not.to.change.when -> result = result * 1 | ||
```coffeescript | ||
result = 0 | ||
(-> result).should.change.when -> result += 1 | ||
expect(-> result).to.change.when -> result -= 1 | ||
expect(-> result).not.to.change.when -> result = result * 1 | ||
``` | ||
@@ -71,6 +69,8 @@ ### `change.by(delta)` | ||
result = 0 | ||
(-> result).should.change.by(3).when -> result += 3 | ||
expect(-> result).not.to.change.by(-3).when -> result += 1 | ||
expect(-> result).to.change.by(-2).when -> result -= 2 | ||
```coffeescript | ||
result = 0 | ||
(-> result).should.change.by(3).when -> result += 3 | ||
expect(-> result).not.to.change.by(-3).when -> result += 1 | ||
expect(-> result).to.change.by(-2).when -> result -= 2 | ||
``` | ||
@@ -82,5 +82,7 @@ ### `change.from(startValue)` | ||
result = ['a', 'b'] | ||
(-> result).should.change.from(['a', 'b']).when -> result.push('c') | ||
(-> result).should.change.from(['a', 'b']).to(['a', 'b', 'c']).when -> result.push('c') | ||
```coffeescript | ||
result = ['a', 'b'] | ||
(-> result).should.change.from(['a', 'b']).when -> result.push('c') | ||
(-> result).should.change.from(['a', 'b']).to(['a', 'b', 'c']).when -> result.push('c') | ||
``` | ||
@@ -92,6 +94,48 @@ ### `change.to(endValue)` | ||
result = ['a', 'b'] | ||
(-> result).should.change.to(['a', 'b', 'c']).when -> result.push('c') | ||
(-> result).should.change.from(['a', 'b']).to(['a', 'c']).when -> result = ['a', 'c'] | ||
```coffeescript | ||
result = ['a', 'b'] | ||
(-> result).should.change.to(['a', 'b', 'c']).when -> result.push('c') | ||
(-> result).should.change.from(['a', 'b']).to(['a', 'c']).when -> result = ['a', 'c'] | ||
``` | ||
## Installation and Setup | ||
### Node | ||
Do an `npm install chai-changes` to get up and running. Then: | ||
```javascript | ||
var chai = require("chai"); | ||
var chaiChanges = require("chai-changes"); | ||
chai.use(chaiChanges); | ||
``` | ||
You can of course put this code in a common test fixture file; for an example using [Mocha][mocha] | ||
### AMD | ||
Chai Changes supports being used as an [AMD][amd] module, registering itself anonymously (just like Chai). So, | ||
assuming you have configured your loader to map the Chai and Chai Changes files to the respective module IDs | ||
`"chai"` and `"chai-changes"`, you can use them as follows: | ||
```javascript | ||
define(function (require, exports, module) { | ||
var chai = require("chai"); | ||
var chaiChanges = require("chai-changes"); | ||
chai.use(chaiChanges); | ||
}); | ||
``` | ||
### `<script>` tag | ||
If you include Chai Changes directly with a `<script>` tag, after the one for Chai itself, then it will | ||
automatically plug in to Chai and be ready for use: | ||
```html | ||
<script src="chai.js"></script> | ||
<script src="chai-changes.js"></script> | ||
``` | ||
## License | ||
@@ -102,1 +146,5 @@ | ||
MIT License (see the LICENSE file) | ||
[chai]: http://chaijs.com/ | ||
[mocha]: http://visionmedia.github.com/mocha/ | ||
[amd]: https://github.com/amdjs/amdjs-api/wiki/AMD |
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
12
144
26872
5
223