mirror of
https://github.com/iptv-org/iptv
synced 2026-09-06 03:50:47 -04:00
fix: make report:create test independent of log output and line endings
The assertion compared stdout against a template literal that could never
match:
- The file was converted from LF to CRLF in 25fa704e14, so the literal
carries \r\n while the command's stdout uses \n.
- The literal starts with a newline, which only exists when consola prints
its [info] lines to stdout ahead of the table. Those are suppressed unless
DEBUG is set, so stdout begins directly at the table border.
Normalize line endings on both sides and trim the leading newline, so the
test asserts what it means to assert: that stdout contains the report table.
It now passes with and without DEBUG=true.
This commit is contained in:
@@ -10,7 +10,8 @@ describe('report:create', () => {
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(
|
||||
stdout.includes(`
|
||||
normalize(stdout).includes(
|
||||
normalize(`
|
||||
┌─────────┬─────────────┬──────────────────┬─────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────────────┐
|
||||
│ (index) │ issueNumber │ type │ streamId │ streamUrl │ status │
|
||||
├─────────┼─────────────┼──────────────────┼─────────────────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────┤
|
||||
@@ -26,7 +27,12 @@ describe('report:create', () => {
|
||||
│ 9 │ 20956 │ 'channel search' │ 'IONTV.us' │ undefined │ 'fulfilled' │
|
||||
│ 10 │ 25157 │ 'streams:add' │ 'OnTimeSports.eg@SD' │ 'OnTime Sports SD.mu38' │ 'invalid_stream_url' │
|
||||
│ 11 │ 39097 │ 'streams:edit' │ '~' │ 'https://jmp2.uk/plu-5a74b8e1e22a61737979c6bf.m3u8' │ 'nonexistent_link' │
|
||||
└─────────┴─────────────┴──────────────────┴─────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────┘`)
|
||||
└─────────┴─────────────┴──────────────────┴─────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────┘`).trim()
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
function normalize(text: string) {
|
||||
return text.replace(/\r\n/g, '\n')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user