Hellow,
我有类似
的东西export class Api {
callHttpClient(url, options, settings) {
this.httpClient.configure(callbackObjectInstance => {
callbackObjectInstance.method();
}); // And then some code
}
}
我怎么能用Jasmine测试框架监视callbackObject.method?
谢谢
答案 0 :(得分:0)
这应该是一种方法。
describe('Given the API', function(){
let api;
let callback;
beforeEach(function(){
api = new Api();
callback = {
method: function() { }
};
spyOn(callback, 'method');
spyOn(api.httpClient, 'configure').and.returnValue(callback);
});
it('should call method', function(){
api.callHttpClient(something, something, something);
expect(callback.method).toHaveBeenCalledTimes(1);
});
});