0

I am writing a jasmine unit-test for a sub-app module using Backbone.Marionette

Can someone give me some idea, what to test?

The module to test looks like this.

/*global define*/
define([
    'app',
    'marionette',
    'tasks/views/list',
    'tasks/views/detailedLayout'
], function (app, Marionette, ListView, DetailedLayout) {
    "use strict";

    var taskApp = new Marionette.Application({

        tasks: function () {
            var listView = new ListView();
            app.mainColumn.show(listView);
        },

        taskDetail: function () {
            app.rightColumn.show(new DetailedLayout());
            this.tasks();
        }

    });

    return taskApp;
});

I will make something like this but I am not sure if this is the the appropriate way:

    describe('Task App', function () {

        beforeEach(function () {
            this.app = taskApp;
        });

        describe('When loading the application', function () {

            it('should be defined the tasks function', function () {
                expect(typeof this.app.tasks).toBeDefined();
            });

            it('should be defined the taskDetail function', function () {
                expect(typeof this.app.taskDetail).toBeDefined();
            });
        });

//app.js

var App = new Marionette.Application();

App.addRegions({
    header: '#header',
    sidebar: '#sidebar',
    mainColumn: '#main-column',
    rightColumn: '#right-column'
});

return App;
Lorraine Bernard
  • 13,000
  • 23
  • 82
  • 134
  • Could you give me more information on `Backbone.Marionette.Application`. How does it deal with your methods like `tasks` and `taskDetails`? – theotheo Jun 22 '12 at 07:32
  • Where are mainColumn and rightColumn come from. I would mock both and test if their show function was called with your views. – Andreas Köberle Jun 24 '12 at 08:50
  • @AndreasKöberle the mainColumn and rightColumn come from the `app.js`. I added the code on my question. thanks. – Lorraine Bernard Jun 24 '12 at 09:17

0 Answers0