Skip to content

Instantly share code, notes, and snippets.

@ghankerson
Last active August 29, 2015 14:02
Show Gist options
  • Save ghankerson/21639d69a73c26b65b17 to your computer and use it in GitHub Desktop.
Save ghankerson/21639d69a73c26b65b17 to your computer and use it in GitHub Desktop.
describe("Isolation", function() {
var obj = {
save: function() {
this.getQuantity();
},
getQuantity: function () {
console.log('returning 5');
return 5;
}
};
it('Should spy on save', function() {
var spy = spyOn(obj, 'getQuantity');
saved = obj.save();
expect(spy).toHaveBeenCalled();
});
});
describe("Isolating login method and calling checkForSimpleLogin", function() {
var app = new Dapp();
var e;
beforeEach(function() {
app.init({}, true);
$('body').click( function(event) {
e = event;
});
$('body').click();
});
it('Should spy on checkForSimpleLogin', function() {
var spy = spyOn(app, "checkForSimpleLogin");
app.login(e);
expect(spy).toHaveBeenCalled();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment