if someone uses backbone + jasmine, then please tell me how you can test this simple idea:

APP.DepartCityView = Backbone.View.extend({ id: 'departCityWidget', template: _.template($('#departCityTpl').html()), render: function () { this.$el.html(this.template()); return this; } }); 

The problem is that I do not understand what exactly here can be tested. here is my attempt:

 describe("DepartCityView:", function() { beforeEach(function () { this.view = new APP.DepartCityView(); }); it ('should init successful', function () { expect(this.view).toBeDefined(); }); it ("produces the correct HTML", function() { this.view.render(); var id = this.view.$el.attr('id'); expect(id).toEqual('departCityWidget'); }); }); 

but even here the second test is clearly useless. but I would like to test in this presentation in general everything that is being tested

here is the template:

 <script type="text/template" id="departCityTpl"> <div class="panel panel-default"> <div class="panel-body row"> <div class="col-xs-12"> <h2>Город отправления</h2> </div> <div class="widget_content form-group col-xs-12"> <input type="text" class="form-control" id="fldDepartCity"> <div id="errMsg_departCity" class="help-block"></div> </div> </div> </div> </script> 
  • one
    The answer is a little off topic. View is a layer between the DOM and the business logic. Therefore, I specifically test the view - we refused. Tests are subject to collections, models and business logic. For testing clicks, choices we use selenium autotests. - Aries Ua

0