Skip to content

Instantly share code, notes, and snippets.

@chris-allnutt
Created December 21, 2011 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-allnutt/1506268 to your computer and use it in GitHub Desktop.
Save chris-allnutt/1506268 to your computer and use it in GitHub Desktop.
Sinon mock not releasing binding after verify on test
// spec for tests on base Collection Class
describe("Moveline.App.Collection", function() {
it("calls stageChangedModel when a collection model is updated", function() {
var model = new Backbone.Model({
'first_name': 'Chris',
'last_name' : 'Allnutt'
});
var collection_mock = sinon.mock(Moveline.App.Collection.prototype).expects('stageChangedModel').once();
var collection = new Moveline.App.Collection([model]);
model.set({
first_name: 'Lee',
last_name: 'Hunter'
});
// verify method called on change
expect(collection_mock.verify()).toEqual(true);
});
//FOLLOWING TEST THROWS ERROR BECAUSE MOCK CONDITION IS STILL BEING CHECKED AND BREAKING
it("adds model to stagedModelChanges array when a collection model is updated", function() {
var model = new Backbone.Model({
'first_name': 'Chris',
'last_name' : 'Allnutt'
});
var collection = new Moveline.App.Collection([model]);
// set fires off a change event returning the model to it
model.set({
first_name: 'Fred',
last_name: 'Cook'
});
// verify method called on change
expect(collection.stagedModelChanges.length).toEqual(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment