angular-scroll-animate
Version:
An Angular.js directive which allows you to perform any javascript actions (in the controller, or on the element) when an element is scrolled into, or out of, the users viewport, without any other dependencies.
37 lines (33 loc) • 1.15 kB
JavaScript
if (typeof require === 'function' && typeof module === 'object') {
var sinon = require('sinon');
var jasmineSinon = require('../lib/jasmine-sinon.js');
}
describe('jasmine matchers gracefully overridden', function() {
beforeEach(function() {
this.methodVal = 'no';
this.api = {
myMethod: function(val) {
this.methodVal = val;
}
};
spyOn(this.api, 'myMethod').andCallThrough();
});
describe('toHaveBeenCalled', function() {
it('should work for jasmine spy', function() {
expect(this.methodVal).toEqual('no');
expect(this.api.myMethod).not.toHaveBeenCalled();
this.api.myMethod.call(this, 'yes');
expect(this.methodVal).toEqual('yes');
expect(this.api.myMethod).toHaveBeenCalled();
});
});
describe('toHaveBeenCalledWith', function() {
it('should work for jasmine spy', function() {
expect(this.methodVal).toEqual('no');
expect(this.api.myMethod).not.toHaveBeenCalledWith('yes');
this.api.myMethod.call(this, 'yes');
expect(this.methodVal).toEqual('yes');
expect(this.api.myMethod).toHaveBeenCalledWith('yes');
});
});
});