//Stub
var ioFile = {
method1:function(){},
method2:function(){}
};
//spyOn
spyOn(ioFile, ‘method1’).and.throwError(“err”);
spyOn(testModule, ‘testMethod’).and.callFake(function(param){
try{
ioFile.method1();
}catch(err){err}
}
var res = testModule.testMethod();
expect(res.message).toEqual(“err”);
댓글
댓글 쓰기