1 | import { formatMS } from "../format";
|
2 |
|
3 | const SECOND_AS_MS = 1000;
|
4 | const MIN_AS_MS = 60 * SECOND_AS_MS;
|
5 | const HOUR_AS_MS = 60 * MIN_AS_MS;
|
6 |
|
7 | describe("formatMS", () => {
|
8 | describe("hours display", () => {
|
9 | it("works with no digits", () => {
|
10 | const value = 2 * HOUR_AS_MS;
|
11 | expect(formatMS(value, 0)).toEqual("2hr");
|
12 | });
|
13 |
|
14 | it("works with 1 digit", () => {
|
15 | const value = 2 * HOUR_AS_MS;
|
16 | expect(formatMS(value, 1)).toEqual("2.0hr");
|
17 | });
|
18 | });
|
19 |
|
20 | describe("minutes display", () => {
|
21 | it("works with no digits", () => {
|
22 | const value = 3 * MIN_AS_MS;
|
23 | expect(formatMS(value, 0)).toEqual("3min");
|
24 | });
|
25 |
|
26 | it("works with 1 digit", () => {
|
27 | const value = 3 * MIN_AS_MS;
|
28 | expect(formatMS(value, 1)).toEqual("3.0min");
|
29 | });
|
30 | });
|
31 |
|
32 | describe("seconds display", () => {
|
33 | it("works with no digits", () => {
|
34 | const value = 4 * SECOND_AS_MS;
|
35 | expect(formatMS(value, 0)).toEqual("4s");
|
36 | });
|
37 |
|
38 | it("works with 1 digit", () => {
|
39 | const value = 4 * SECOND_AS_MS;
|
40 | expect(formatMS(value, 1)).toEqual("4.0s");
|
41 | });
|
42 | });
|
43 | });
|