Skip to content

Commit 01a058f

Browse files
committed
Fix formatAudioDuration
1 parent 5f44f86 commit 01a058f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

dotcom-rendering/src/components/ListenToArticle.importable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export const formatAudioDuration = (
1717
const minutes = Math.floor((durationInSeconds % 3600) / 60);
1818
const seconds = durationInSeconds % 60;
1919

20-
const formattedDuration = `${
21-
minutes > 0 ? minutes.toString().padStart(1, '0') : '0'
22-
}:${seconds > 0 ? seconds.toString().padStart(2, '0') : '00'}`;
20+
const formattedDuration = `${minutes.toString()}:${seconds
21+
.toString()
22+
.padStart(2, '0')}`;
2323

2424
return formattedDuration;
2525
};

dotcom-rendering/src/components/ListenToArticle.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { formatAudioDuration } from './ListenToArticle.importable';
22

33
describe('format Audio Duration correctly', () => {
44
const testCases = [
5-
{ input: -60, expected: '' },
6-
{ input: 0, expected: '' },
5+
{ input: -60, expected: undefined },
6+
{ input: 0, expected: undefined },
77
{ input: 1, expected: '0:01' },
88
{ input: 59, expected: '0:59' },
99
{ input: 60, expected: '1:00' },
1010
{ input: 61, expected: '1:01' },
1111
{ input: 3599, expected: '59:59' },
12-
{ input: 3600, expected: '' },
12+
{ input: 3600, expected: undefined },
1313
];
1414

1515
for (const { input, expected } of testCases) {

0 commit comments

Comments
 (0)