mercredi 14 septembre 2016

How to test bootstrap popover call in anonymous function

I have this right at the start of my controller:

$(function() {
        $("[data-toggle='popover']").popover();
    });

I would like to test that .popover was called. And tried using what was in this question: Testing directive that uses bootstrap popover

So my test looks like:

it('sets up bootstrap popups',function(){
            spyOn($.fn, 'popover');
            expect($.fn.popover).toHaveBeenCalled;

        });

The test passes but if I remove that function altogether from my controller the test still passes. I think it has something to do with I should spy on the outer anonymous function and check $.fn calls popover inside but am unsure how to do this.

Any ideas? Thank you

Aucun commentaire:

Enregistrer un commentaire