Skip to content

Commit

Permalink
solutions spec
Browse files Browse the repository at this point in the history
  • Loading branch information
learyjk committed Nov 14, 2023
1 parent edbf5a9 commit 2edd665
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/02-1-functions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe("formatTime function", () => {
it("should correctly format time for a range of seconds", () => {
expect(formatTime(125)).toEqual("02:05");
expect(formatTime(60)).toEqual("01:00");
expect(formatTime(59)).toEqual("00:59");
expect(formatTime(0)).toEqual("00:00");
// Add more cases as needed
});
});

describe("formatTime function", () => {
it("should count up to the specified number of seconds and log each second", (done) => {
spyOn(console, "log");
countUpTo(3);
setTimeout(() => {
expect(console.log).toHaveBeenCalledWith("Elapsed time: 00:01");
expect(console.log).toHaveBeenCalledWith("Elapsed time: 00:02");
expect(console.log).toHaveBeenCalledWith("Elapsed time: 00:03");
expect(console.log).toHaveBeenCalledWith("Time's up!");
done();
}, 3500); // Slightly more than 3 seconds to ensure all intervals have run
});
});

0 comments on commit 2edd665

Please sign in to comment.