Skip to content

Instantly share code, notes, and snippets.

@lijie2000
Last active August 29, 2015 14:01
Show Gist options
  • Save lijie2000/6fcaacaa025748bee943 to your computer and use it in GitHub Desktop.
Save lijie2000/6fcaacaa025748bee943 to your computer and use it in GitHub Desktop.
define(['underscore'
], function (_) {
'use strict';
describe('a spy', function () {
console.log('settings check in <<<');
var foo, bar = null;
beforeEach(function () {
foo = {
setBar: function (value) {
bar = value;
}
};
spyOn(foo, 'setBar');
foo.setBar(123);
foo.setBar(456, 'another param');
});
it('tracks that the spy was called', function () {
expect(foo.setBar).toHaveBeenCalled();
});
it('tracks all the arguments of its calls', function () {
expect(foo.setBar).toHaveBeenCalledWith(123);
expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');
});
it('tests underscore', function () {
expect(_.size([1, 2, 3])).toBe(3);
});
});
});
@lijie2000
Copy link
Author

when run grunt test, got error

test/spec/settings/settingSpec.js
line 17 col 7 'spyOn' is not defined.

Same kind of error when use jasmine.createSpy(),
jasmine is not defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment