0

I am using jasmine 2.0 for testing javascript functions. I have backbone code which is written below.

 events:{
    "click #div1":"div1Clicked"
}

div1Clicked:function(){
   onComplete = function(){
                some functionality

            };
 onComplete();
}

I have written test case with jasmin which looks like following:

describe('View : Test View', function() {
    beforeEach(function(){
        testView = new View();

     });
   describe('div1Clicked',function(){
        it('Should call div1Clicked',function(){
            spyOn(testView,'div1Clicked').and.callThrough();
            testView.div1Clicked();
            expect(testView.div1Clicked).toHaveBeenCalled();
        });
    });   

 });

How to write test case for onComplete inside div1Clicked function?

Guy
  • 65,082
  • 97
  • 254
  • 325
Priya
  • 1,453
  • 4
  • 29
  • 55
  • I don't think there is a way to spyOn a private function. You might want to test the functionality inside the onComplete function is being called. – skud Dec 30 '14 at 16:01
  • Why do you have onComplete setup as a variable and then called immediately afterwards? You should just be able to execute "some functionality" right away in the function(). That might give me a clearer picture to be able to help you... – Guy May 29 '15 at 23:45

0 Answers0