Skip to content

Commit 6790759

Browse files
committed
fix: add test coverage for --hls option without argument
Previously missing test for the case where --hls is provided but no directory argument is given. Also refined validation to be more precise about what constitutes an invalid directory path.
1 parent 45529f1 commit 6790759

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/bin/tcx2webvtt.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,12 @@ describe('tcx2webvtt CLI', { timeout: 10000 }, () => {
295295
expect(mockProcess.exit).toHaveBeenCalledWith(1)
296296
})
297297

298-
it('should error when HLS directory path is whitespace only', async () => {
299-
const tcxFile = join(__dirname, '../../fixtures/tcx/concept2.tcx')
300-
mockProcess.argv.push('--hls', ' ', tcxFile)
298+
it('should error when --hls option has no argument', async () => {
299+
mockProcess.argv.push('--hls')
301300

302301
await main(mockProcess)
303302

304-
expect(stderr).toContain('HLS directory path cannot be empty')
303+
expect(stderr).toContain("Option '--hls <value>' argument missing")
305304
expect(mockProcess.exit).toHaveBeenCalledWith(1)
306305
})
307306

src/bin/tcx2webvtt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function main(proc: ProcessLike) {
9191
}
9292

9393
// Validate HLS directory argument
94-
if (values.hls !== undefined && !values.hls.trim()) {
94+
if (values.hls !== undefined && values.hls === '') {
9595
proc.stderr.write('Error: HLS directory path cannot be empty\n')
9696
proc.exit(1)
9797
}

0 commit comments

Comments
 (0)