В моем компоненте AudioPlayer у меня есть метод download ():
download() {
this.audio.pause();
window.open(this.file, "download");
},
Я могу проверить первую строку:
this.audio.pause();
Но как мне проверить (следует ли мне? Вторая строка:
window.open(this.file, "download");
Вот мой текущий тест спецификации файла
it("should open a window from downloadBtn", async () => {
// jsdom doesn't support any loading or playback media operations.
// As a workaround you can add a few stubs in your test setup:
window.HTMLMediaElement.prototype.pause = () => { /* do nothing */ };
// given
const wrapper = mount(AudioPlayer, {
attachToDocument: true,
propsData: {
autoPlay: false,
file: file,
ended,
canPlay
}
});
const downloadBtn = wrapper.find("#downloadBtn");
wrapper.vm.loaded = true; // enable downloadBtn
// when
downloadBtn.trigger("click");
await wrapper.vm.$nextTick();
// then
expect(wrapper.vm.paused).toBe(true);
});
спасибо за отзыв