2022-02-05 06:12:17 +01:00
|
|
|
const fs = require('fs-extra')
|
2021-12-12 05:13:02 +01:00
|
|
|
const path = require('path')
|
|
|
|
const { execSync } = require('child_process')
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-02-05 06:12:17 +01:00
|
|
|
fs.emptyDirSync('tests/__data__/temp')
|
|
|
|
fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db')
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:12:17 +01:00
|
|
|
const stdout = execSync(
|
|
|
|
'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/update-playlists.js',
|
|
|
|
{ encoding: 'utf8' }
|
|
|
|
)
|
2021-12-12 05:13:02 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('can update playlist', () => {
|
2022-02-05 06:21:31 +01:00
|
|
|
expect(content('tests/__data__/output/channels/ad.m3u')).toBe(
|
|
|
|
content('tests/__data__/expected/channels/ad.m3u')
|
|
|
|
)
|
2022-02-05 06:12:17 +01:00
|
|
|
|
2022-02-05 06:21:31 +01:00
|
|
|
expect(content('tests/__data__/output/channels/ru.m3u')).toBe(
|
|
|
|
content('tests/__data__/expected/channels/ru.m3u')
|
|
|
|
)
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:21:31 +01:00
|
|
|
expect(content('tests/__data__/output/channels/uk.m3u')).toBe(
|
|
|
|
content('tests/__data__/expected/channels/uk.m3u')
|
|
|
|
)
|
2021-12-12 05:13:02 +01:00
|
|
|
})
|
2022-02-05 06:12:17 +01:00
|
|
|
|
|
|
|
function content(filepath) {
|
|
|
|
return fs.readFileSync(path.resolve(filepath), {
|
|
|
|
encoding: 'utf8'
|
|
|
|
})
|
|
|
|
}
|