Skip to content

Instantly share code, notes, and snippets.

@pheuter
Created November 21, 2012 19:32
Show Gist options
  • Save pheuter/4127113 to your computer and use it in GitHub Desktop.
Save pheuter/4127113 to your computer and use it in GitHub Desktop.
backbone.computedfields marionette.collectionview unit test
describe('when ComputedFields initialized in Backbone.Model via Marionette.CollectionView', function () {
var model, collection, collectionView;
beforeEach(function () {
var Model = Backbone.Model.extend({
initialize: function () {
this.computedFields = new Backbone.ComputedFields(this);
},
grossPrice: {
get: function () {
return 100;
}
}
});
var Collection = Backbone.Collection.extend({
model: Model
});
var CollectionView = Marionette.CollectionView.extend({
itemView: Marionette.ItemView
});
model = new Model({ netPrice: 100, vatRate: 5});
collection = new Collection([model]);
collectionView = new CollectionView({
collection: collection
});
});
it ('should be initialized', function () {
expect(model.computedFields).to.exist;
expect(model.computedFields._computedFields.length).to.equal(1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment