Jasmine 杜兰达尔事件的茉莉花试验
我感到惊讶的是,我没有在文档或博客文章中找到任何关于这方面的帮助 我正在尝试添加测试,以确保事件设置正确并保持这种状态。 Require中的durandal应用程序和事件对象为空。因此,在它们可用之前,必须有一个我不知道的设置步骤 我有一个击倒视图模型:Jasmine 杜兰达尔事件的茉莉花试验,jasmine,durandal,durandal-2.0,Jasmine,Durandal,Durandal 2.0,我感到惊讶的是,我没有在文档或博客文章中找到任何关于这方面的帮助 我正在尝试添加测试,以确保事件设置正确并保持这种状态。 Require中的durandal应用程序和事件对象为空。因此,在它们可用之前,必须有一个我不知道的设置步骤 我有一个击倒视图模型: define([ 'knockout', 'durandal/events', 'durandal/app', 'Common/Modules/KoComponents/slideInEventListKeys'
define([
'knockout',
'durandal/events',
'durandal/app',
'Common/Modules/KoComponents/slideInEventListKeys'
],
function (ko, durandalEvents, durandalApp, slideInEventListKeys) {
function SlideInVm(params) {
// listen for anyone broadcasting this specific event.
durandalEvents.includeIn(this);
var _this = this;
durandalApp.on(slideInEventListKeys.open).then(function () {
_this.isShowing(true);
});
durandalApp.on(slideInEventListKeys.close).then(function () {
_this.isShowing(false);
});
}
SlideInVm.prototype.isShowing = ko.observable(false);
});
茉莉花:
define([
'knockout',
'Common/Modules/slideInVm',
'durandal/events',
'durandal/app',
'Common/Modules/slideInEventListKeys'
],
function (ko, SlideInVm, durandalEvents, durandalApp, slideInEventListKeys) {
'use strict';
describe('Given the Slide In component', function () {
var vm;
beforeEach(function(){
vm = new SlideInVm();
});
it('Should subscribe for open events', function () {
debugger;
// events and app are null!
// how to check this?
});
it('Should subscribe for close events', function () {
});
describe('When opening', function(){
beforeEach(function(){
// how to trigger this if app is null?
app.trigger(slideInEventListKeys.open);
});
it('Should show the component', function(){
expect(vm.isShowing()).toBeTruthy();
});
});
});
});