You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iptv/tests/commands/playlist/update.test.ts

38 lines
1.0 KiB
TypeScript

1 year ago
import { execSync } from 'child_process'
import * as fs from 'fs-extra'
import { glob } from 'glob'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
1 year ago
fs.copySync('tests/__data__/input/streams_update', 'tests/__data__/output/streams')
1 year ago
})
it('can format playlists', () => {
const stdout = execSync(
1 year ago
'DEBUG=true DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/output/streams npm run playlist:update --silent',
1 year ago
{
encoding: 'utf8'
}
)
const files = glob
1 year ago
.sync('tests/__data__/expected/streams_update/*.m3u')
.map(f => f.replace('tests/__data__/expected/streams_update/', ''))
1 year ago
files.forEach(filepath => {
1 year ago
expect(content(`output/streams/${filepath}`), filepath).toBe(
content(`expected/streams_update/${filepath}`)
)
1 year ago
})
1 year ago
expect(stdout).toBe(
`OUTPUT=closes #14151, closes #14140, closes #14139, closes #14110, closes #14179, closes #14178\n`
)
1 year ago
})
function content(filepath: string) {
return fs.readFileSync(`tests/__data__/${filepath}`, {
encoding: 'utf8'
})
}