如果我保持对index_list[1] = [2,3]
的调用,index_list = [[7,8,9],[2,3],[5,6],[0],[1],[4]]
的测试将失败,但预期将通过。如果我评论$httpBackend.flush()
电话,期望就会失败。当我在获取当天的服务中放置一个断点时,它被调用并且承诺正在解决,我可以进入No Pending Requests
它被调用。可能是导致它的另一个测试吗?
flush
我在beforeEach中有addIssues
。 (没有 it("should pass",
function() {
scope.issues = [];
scope.requestChanges.issues = [
{
title: "File Mismatch",
affects_2d_file: true,
affects_3d_file: true,
resolved_at: null
},
{
title: "Missing Files",
affects_2d_file: true,
affects_3d_file: true,
resolved_at: null
}
];
spyOn(TEST.$state, "go");
spyOn(TEST.notification_service, "pushSuccessMessage");
TEST.$httpBackend.expectPOST("/some/url")
.respond(200,{
part_issues: scope.requestChanges.issues
});
scope.addIssues(); //this makes makes the http request.
TEST.$httpBackend.flush(); //expects pass, but no pending request
scope.part.issues.forEach(function(e, i) {
var issue = e;
var change = scope.requestChanges.issues[i];
expect(_.isEqual(issue, change)).toBe(true);
});
//TEST.$httpBackend.flush(); expects fail
});
调用beforeEach`)