I would like to test the behavior of a module (using Marionette ) that works (1).
Oddly enough, js-module (1) works, but unit test (2) using Jasmine fails.
Any ideas?
(1)
define([ 'marionette', 'tasks/views/item', 'text!tasks/templates/list.html', 'collections/tasks' ], function (Marionette, itemView, listTemplate, TaskCollection) { "use strict"; var ListView = Marionette.CompositeView.extend({ initialize: function () { this.collection = new TaskCollection(); this.collection.fetch(); }, template: listTemplate, itemView: itemView, appendHtml: function (collectionView, itemView) { collectionView.$el.find('ul.tasks').append(itemView.el); } }); return ListView; });
(2)
// spec file it("should add a new element", function () { // TODO var itemView = new Backbone.View(), collectionView = new Backbone.View(); this.view.appendHtml(collectionView, itemView); expect(this.view.$el.find('ul.tasks').length).toEqual(1); // Expected 0 to equal 1. });
source share