mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
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:
parent
bc7766efe1
commit
be3b024b0b
2 changed files with 6 additions and 6 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue