Created
December 21, 2011 14:43
-
-
Save chris-allnutt/1506268 to your computer and use it in GitHub Desktop.
Sinon mock not releasing binding after verify on test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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