Fix regression in getTimeStr

When we switched getTimeObj to return strings, our sketchy zero check started to fail. Luckily our tests caught it!
This commit is contained in:
Jordan Eldredge 2018-09-17 08:32:52 -07:00
parent bc7766efe1
commit be3b024b0b
2 changed files with 6 additions and 6 deletions

View file

@ -21,10 +21,10 @@ describe("getTimeObj", () => {
it("expresses seconds as an object", () => {
const actual = getTimeObj(1234);
const expected = {
minutesFirstDigit: 2,
minutesSecondDigit: 0,
secondsFirstDigit: 3,
secondsSecondDigit: 4
minutesFirstDigit: "2",
minutesSecondDigit: "0",
secondsFirstDigit: "3",
secondsSecondDigit: "4"
};
expect(actual).toEqual(expected);
});

View file

@ -51,7 +51,7 @@ export const getTimeObj = (time: number | null): Time => {
};
};
export const getTimeStr = (time: number, truncate = true): string => {
export const getTimeStr = (time: number, truncate: boolean = true): string => {
if (time == null) {
return "";
}
@ -63,7 +63,7 @@ export const getTimeStr = (time: number, truncate = true): string => {
} = getTimeObj(time);
return [
truncate ? minutesFirstDigit || "" : minutesFirstDigit,
truncate && minutesFirstDigit === "0" ? "" : minutesFirstDigit,
minutesSecondDigit,
":",
secondsFirstDigit,