// This program has been developed by students from the bachelor Computer Science at Utrecht
// University within the Software Project course.
// © Copyright Utrecht University (Department of Information and Computing Sciences)
import formatDuration from "../../src/utils/formatDuration.ts";

describe("formatting durations (unit)", () => {
  it("does one millisecond", () => {
    const result = formatDuration(1);
    expect(result).toBe("00:00:00.001");
  });

  it("does one-hundred twenty-three milliseconds", () => {
    const result = formatDuration(123);
    expect(result).toBe("00:00:00.123");
  });

  it("does one second", () => {
    const result = formatDuration(1*1000);
    expect(result).toBe("00:00:01.000");
  });

  it("does thirteen seconds", () => {
    const result = formatDuration(13*1000);
    expect(result).toBe("00:00:13.000");
  });

  it("does one minute", () => {
    const result = formatDuration(60*1000);
    expect(result).toBe("00:01:00.000");
  });

  it("does thirteen minutes", () => {
    const result = formatDuration(13*60*1000);
    expect(result).toBe("00:13:00.000");
  });

  it("does one hour", () => {
    const result = formatDuration(60*60*1000);
    expect(result).toBe("01:00:00.000");
  });

  it("does thirteen hours", () => {
    const result = formatDuration(13*60*60*1000);
    expect(result).toBe("13:00:00.000");
  });

  it("does negative one millisecond", () => {
    const result = formatDuration(-1);
    expect(result).toBe("-00:00:00.001");
  });

  it("does large negative durations", () => {
    const result = formatDuration(-(123*60*60*1000 + 59*60*1000 + 59*1000 + 123));
    expect(result).toBe("-123:59:59.123");
  });
});
