【发布时间】:2014-05-05 09:19:37
【问题描述】:
在 Jasmine 测试中,我有以下内容:
CommentMock = function() {};
CommentMock.prototype.save = function() {
// stuff
};
spyOn( CommentMock.prototype, 'save' ).andCallThrough();
但是,我收到此错误:
Failure/Error: save() method does not exist
在 Angular 控制器中我有这个:
$scope.newComment = new Comment();
$scope.processComment = function( isValid ) {
if ( isValid ) {
Comment.save( $scope.newComment )
.$promise
.then(
function() {
// success stuff
},
function() {
// error junk
}
);
}
};
【问题讨论】:
-
你能发表评论吗?这是一项服务吗?如果是这样,它返回一个对象而不是函数
标签: javascript angularjs jasmine