0
PlayOscillator(hz: number = 400, durationInSeconds: number = 1){
this._Oscillators[0].frequency.value = hz;
this._Oscillators[0].connect(this._MainGainNode);
this._activeOscillatorIndex = 0;
setTimeout(() => {
console.info("time out called");
this._Oscillators[this._activeOscillatorIndex].disconnect(this._MainGainNode);
this._Oscillators[this._activeOscillatorIndex] = undefined;
}, durationInSeconds * 1000);
}
我想测试typeof
this._Oscillators[0]
执行setTimeout后,但我无法做到这一点。我已经在这里找到了所有解决方案推荐功能不可用茉莉花2.5如何测试在茉莉花2.5中触发setTimeout的函数?
我迄今
it('Should switch from one oscillator to another',()=>{
let wap = webAudioApiProvider;
expect(wap._Oscillators[0]).toBeUndefined();
expect(()=>{wap.PlayOscillator(freq,duration)}).not.toThrow();
expect(wap._Oscillators[0]).toBeUndefined();
});
到目前为止,您的测试代码在哪里? – JLRishe
对不起,我以为我贴了它。当我从杂货店回来时,我会在10分钟内编辑我的问题。它只是一个三行代码,期望不会丢失。 ToBe – distante
@JLRishe更新! – distante