expect-change

0.0.1 • Public • Published

expect-change Build Status

Change assertion extension for expect.js

var cnt = 0;
    
expect(function() { cnt = 101; }).to
    .change(function() { return cnt; });

var cnt = 0;

expect(function() { cnt = 101; }).to
    .change(function() { return cnt; }).from(0).to(101);

var cnt = 0;

expect(function() {    
  expect(function() { cnt = 0; }).to
      .change(function() { return cnt; });
}).to.throwException();

var cnt = 0;
    
expect(function() {
  expect(function() { cnt = 101; }).to.not
      .change(function() { return cnt; });
}).to.throwException();

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.js

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

Dependents (0)

Package Sidebar

Install

npm i expect-change

Weekly Downloads

2

Version

0.0.1

License

none

Last publish

Collaborators

  • p-baleine