Comparing version 1.7.0 to 1.8.0
@@ -22,9 +22,42 @@ var expect = require('../index'); | ||
var video = { | ||
play: function () {}, | ||
pause: function () {}, | ||
rewind: function () {} | ||
play: function () {} | ||
}; | ||
var spy; | ||
beforeEach(function () { | ||
spy = expect.spyOn(video, 'play'); | ||
video.play('some', 'args'); | ||
}); | ||
it('tracks the number of calls', function () { | ||
expect(spy.calls.length).toEqual(1); | ||
}); | ||
it('tracks the context that was used', function () { | ||
expect(spy.calls[0].context).toBe(video); | ||
}); | ||
it('tracks the arguments that were used', function () { | ||
expect(spy.calls[0].arguments).toEqual([ 'some', 'args' ]); | ||
}); | ||
it('was called', function () { | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
it('was called with the correct args', function () { | ||
expect(spy).toHaveBeenCalledWith('some', 'args'); | ||
}); | ||
it('can be restored', function () { | ||
expect(video.play).toEqual(spy); | ||
spy.restore(); | ||
expect(video.play).toNotEqual(spy); | ||
}); | ||
}); | ||
describe('An undefined property that was spied on using spyOn', function () { | ||
var video = {}; | ||
var spy; | ||
beforeEach(function () { | ||
@@ -31,0 +64,0 @@ spy = expect.spyOn(video, 'play'); |
@@ -213,3 +213,8 @@ var assert = require('assert'); | ||
function noop() {} | ||
function createSpy(fn) { | ||
if (fn == null) | ||
fn = noop; | ||
expect(fn).toBeA(Function); | ||
@@ -269,12 +274,9 @@ | ||
expect(original).toBeA( | ||
Function, | ||
formatString('%s does not have a method named "%s"', inspect(object), methodName) | ||
); | ||
if (original == null || !original.__isSpy) { | ||
var spy = createSpy(original); | ||
if (!original.__isSpy) { | ||
var spy = createSpy(original); | ||
spy.restore = function () { | ||
spy.restore = spy.destroy = function () { | ||
object[methodName] = original; | ||
}; | ||
object[methodName] = spy; | ||
@@ -281,0 +283,0 @@ } |
{ | ||
"name": "expect", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Write better assertions", | ||
@@ -5,0 +5,0 @@ "main": "modules/index.js", |
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
26385
619