this.result = new Promise( function( resolve, reject ){
self.resolveMethod = resolve;
self.rejectMethod = reject;
});
如何测试resolveMethod和rejectMethod是函数?感谢
答案 0 :(得分:2)
使用此辅助方法并断言。
function isFunctionA(object) {
return object && getClass.call(object) == '[object Function]';
}
答案 1 :(得分:0)
您可以尝试以下方式:
expect(type(result.resolveMethod).toBe('function');
expect(type(result.rejectMethod).toBe('function');
答案 2 :(得分:0)
这对我有用
describe('result', function() {
it('should assign resolve function to resolveMethod', function() {
expect( instance.resolveMethod ).toEqual( jasmine.any(Function) );
});
it('should assign reject function to rejectMethod', function() {
expect( instance.rejectMethod ).toEqual( jasmine.any(Function) );
});
});