Change assertion extension for expect.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
support
test
.gitignore
.travis.yml
Makefile
Readme.md
bower.json
index.js
package.json

Readme.md

expect-change Build Status

Change assertion extension for expect.js

// sample obj
var counter = {
  increment: function() {
    this.counter = this.counter || 0;
    this.counter += 1;
  },
  count: function() {
    return (this.counter = this.counter || 0);
  }
};

// expectation
expect(function() { counter.increment(); })
    .to.change(function() { return counter.count(); }).from(0).to(1);

How to use

Node

Install expect.js and expect-change with NPM or add it to your package.json:

$ npm install expect.js expect-change

Then:

var expect = require('expect.js'),
    expectChange = require('expect-change');

Browser

Include script tag after expect.js

<script src="expect.js"></script>
<script src="expect-change.js"></script>

API

change: check if the value is changed

to: check if the value is changed to expected value

from: heck if the value is changed from expected value