我正在使用Backbone.Marionette为子应用模块编写茉莉花单元测试
有人可以给我一些想法,测试什么?
要测试的模块如下所示。
/*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;
});
我会做这样的事情,但我不确定这是否合适:
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;