I have two Backbone Views, MainViewand PopupView.
MainView contains a help button. When the help button handler starts, it shows Backbone.View.
My question is how to test this behavior with a module MainView?
Here is my code about MainView:
var MainView = Backbone.View.extend({
events: {
'click #help' : 'showPopUp'
},
showPopUp: function() {
var popupView = new PopupView();
app.vent.trigger('showModal', popupView);
}
});
Here is my code about mainView.spec:
describe("When help button handler fired", function() {
beforeEach(function() {
this.view.render();
this.view.$el.find('#help').trigger('click');
});
it("shows the popup", function() {
});
});
Here is my application code:
var app = new Marionette.Application();
app.addRegions({
header: '#header',
sidebar: '#sidebar',
main: '#main',
modal: '#modal'
});
app.vent.on('showModal', function(view) {
var modal = app.modal;
modal.show(view);
modal.$el.modal({
show: true,
keyboard: true,
backdrop: 'static'
});
});
source
share