2
this.result = new Promise( function( resolve, reject ){
   self.resolveMethod = resolve;
   self.rejectMethod = reject;
});

How can I test resolveMethod and rejectMethod are functions? Thanks

Sasindu H
  • 1,538
  • 7
  • 24
  • 43
  • Possible duplicate of [How can I check if a javascript variable is function type?](http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type) – Caramiriel Sep 08 '16 at 10:26

3 Answers3

2

Use this helper method and assert.

function isFunctionA(object) {
 return object && getClass.call(object) == '[object Function]';
}
Herr Derb
  • 4,977
  • 5
  • 34
  • 62
0

You could try something like:

expect(type(result.resolveMethod).toBe('function');
expect(type(result.rejectMethod).toBe('function');
Pedro Vaz
  • 820
  • 5
  • 11
0

This is working for me

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) );
    });       
});
Sasindu H
  • 1,538
  • 7
  • 24
  • 43