2.0.2 • Published 10 years ago

jasmine-n-matchers v2.0.2

Weekly downloads
11
License
MIT
Repository
github
Last release
10 years ago

jasmine-n-matchers

A set of matchers to assert a spy was called n times

The 2.0.0 release supports Jasmine 2.0. Everything earlier is for Jasmine 1.3.

Usage

Make sure the jasmine-n-matchers.js file is executed early in your tests, it uses beforeEach to register the matchers.

Example

var spy = jasmine.createSpy('spy');

expect(spy).toHaveBeenCalledNTimes(0);

spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(1);
expect(spy).toHaveBeenCalledOnce();
expect(spy).toHaveBeenCalledOnceWith('foo', 'bar');

spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(2);
expect(spy).toHaveBeenCalledTwice();
expect(spy).toHaveBeenCalledTwiceWith('foo', 'bar');

spy('bar', 'baz');

expect(spy).toHaveBeenCalledNTimes(3);
expect(spy).toHaveBeenCalledThrice();
expect(spy).toHaveBeenCalledTwiceWith('foo', 'bar');
expect(spy).toHaveBeenCalledOnceWith('bar', 'baz');

spy('foo', 'bar');
spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(5);
expect(spy).toHaveBeenCalledNTimesWith(4, 'foo', 'bar');
2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

0.0.3

10 years ago