Я хочу написать тест для моего setInterval и проверить, что окно предупреждения запущено со значением «pulse». Как мне это сделать? Я пробовал так много вариаций на этом, но не могу понять этого. Я предоставил код и файл спецификации. Я использую жасмин 2.0. Любая помощь приветствуется.как написать тест жасмина для setinterval внутри прототипа
countTimer.js
function CountTimer(timelength){
this.timelength = timelength;
this.running = false;
}
CountTimer.prototype.start = function(){
this.running = true;
setInterval(function() {alert('pulse')}, 2000);
};
CountTimer.prototype.stop = function(){
this.running = false;
};
countTimerSpec.js
describe("Timer",function() {
var myTimer;
beforeEach(function() {
myTimer = new CountTimer(25);
});
...
it("start should run setInterval 'pulse' every 2 seconds via setInterval", function(){
myTimer.start();
//what goes here???
expect(sut.callback).toHaveBeenCalled();
});
});