function showProgress(status) {
status.message = "Loading";
for (var time = 1000; time <= 3000; time += 1000) {
// Append a '.' to the message every second for 3 secs.
setTimeout(function() {
status.message += ".";
}, time);
}
setTimeout(function() {
// Special case for the 4th second.
status.message = "Done";
}, 4000);
}
function testUpdatesStatusMessageOverFourSeconds() {
Clock.reset(); // Clear any existing timeout functions on the event queue.
var status = {};
showProgress(status); // Call our function.
assertEquals("Loading", status.message);
Clock.tick(2000); // Call any functions on the event queue that have
// been scheduled for the first two seconds.
assertEquals("Loading..", status.message);
Clock.tick(2000); // Same thing again, for the next two seconds.
assertEquals("Done", status.message);
}
Yay! TotT is back!
ReplyDelete