Created
November 21, 2012 19:32
-
-
Save pheuter/4127113 to your computer and use it in GitHub Desktop.
backbone.computedfields marionette.collectionview unit 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
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