jack-expect

0.1.0 • Public • Published

NPM version Build Status Coverage Status

jack-expect

Synopsis

Expect.js assertions for Jack.js test doubles

Usage

// Setup:
 
var expect = require('expect.js');
 
require('jack-expect')(expect);
// subject:
 
var out = {
  test: function() {},
  other: function() {}
};
 
// test double
 
jack(out, 'test');

testDouble

Verify that a function is a test double.

expect(out.test).to.be.testDouble();
expect(out.not).to.not.be.testDouble();

invoked

Verify that a test double has been invoked.

expect(out.test).invoked();
expect(out.test).not.invoked();

max

Verify that a test double has been called max n times.

expect(out.test).max(1);
expect(out.test).not.max(2);

min

Verify that a test double has been called min n times.

expect(out.test).min(1);
expect(out.test).not.min(2);

exactly

Verify that a test double has been called exactly n times.

expect(out.test).exactly(1);
expect(out.test).not.exactly(2);

once

Verify that a test double has been called exactly once.

expect(out.test).once();
expect(out.test).not.once();

twice

Verify that a test double has been called exactly twice.

expect(out.test).twice();
expect(out.test).not.twice();

on

Verify that a test double has been called on given context.

expect(out.test).on(context);
expect(out.test).not.on(context);

args/withArgs

Verify that a test double has been called with given arguments.

expect(out.test).withArgs('foo', 'bar');
expect(out.test).not.withArgs('foo', 'bar', 'baz');

Installation

npm:

npm install jack-expect

component:

component install jackjs/jack-expect

Standalone:

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

Tests

$ npm test

Coverage:

$ npm run coverage

License

(The MIT License)

Copyright (c) 2013 Veselin Todorov hi@vesln.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i jack-expect

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • vesln