mercredi 10 août 2016

Prevent video playing call in jasmine

I have an angular function on a button doing the following:

vm.play_btn_clicked = function() {
        document.querySelector("#culture-video").play()
        vm.play_btn_visible = false;

    }

I want to test this function in jasmine, but only the boolean part of it. However, when i try to test it with the following:

expect(vm.play_btn_visible).toEqual(true);
    vm.play_btn_clicked();
    expect(vm.play_btn_visible).toEqual(false);

I get that querySelector() returned null. Is there a way to either bypass this call or to have a mock object responding to the querySelector()?

Aucun commentaire:

Enregistrer un commentaire