backbone.js - Jasmine / Backbone -
my jasmine tests used pass. however, implemented base backbone view provides functionality few common views. after this, cannot simple test below pass. seems dom element (div) not exist, show view not rendering properly. thoughts or recommendations on why occurring , ways solve it?
two backbone views, 1 extends off of other:
var stockshowview = base.extend({ tagname: 'div', classname: 'showsecurity', template: _.template(showtpl), .... render: function() { this.$el.html(this.template({ stock: this.model.tojson() })); } ....return stockshowview; var base = backbone.view.extend({ initialize: function() {....//no render function
jasmine test
stock_showview = new stockshowview({model: model}); stock_showview.render(); expect(stock_showview.tagname).toequal('div');
error
cannot read property 'length' of undefined
router
router.on('route:showpost', function(id) { if (globals.stocks) { var stockpost = new stockmodel({_id: id}); stockpost.fetch({ reset: true, success: function(stockpost) { var stock_showview = new stockshowview({model: stockpost}); $("#view_box").html(stock_showview.render().el); } });
you should write tagname element uppercase letters. try this:
expect(stock_showview.el.nodename).toequal("div");
Comments
Post a Comment