在我的控制器中有一个功能......
function showDesktopPreview() {
var self = this;
this.$uibModal.open({
templateUrl: 'app/templates/modals/desktopPreview/template.desktopPreview.html',
controller: 'TemplateDesktopPreviewModalController',
controllerAs: 'vm',
size: 'xl',
resolve: {
previewUrl: function previewUrl() {
return self.getFrameUrl();
}
}
});
}
}
现在我写下Karma测试脚本如下....
describe('When calling the showDesktopPreview function', () => {
let modalOptions;
let previewUrl;
beforeEach(() => {
TemplatesCreateController = createController();
//previewUrl = TemplatesCreateController.getFrameUrl();
modalOptions = {
templateUrl: 'app/templates/modals/desktopPreview/template.desktopPreview.html',
controller: 'TemplateDesktopPreviewModalController',
controllerAs: 'vm',
size: 'x1',
resolve: {
previewUrl: (value) => {
return value() === TemplatesCreateController.previewUrl();
}
}
};
console.log(modalOptions.resolve.previewUrl);
TemplatesCreateController.showDesktopPreview();
});
it('should instantiate the $uibModal service ', () => {
expect(TemplatesCreateController.$uibModal).to.not.be.an('undefined');
});
it('should call $uibModal.open with correct params', () => {
scope.$apply();
expect(TemplatesCreateController.$uibModal.open).to.have
.been.called
.and.be.calledWithMatch({modalOptions});
});
});
这是错误的
断言错误:预期已通过匹配
的参数调用open请帮我解决此问题。