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:12:17 +01:00
|
|
|
const output1 = content('tests/__data__/output/channels/ad.m3u')
|
|
|
|
const expected1 = content('tests/__data__/expected/channels/ad.m3u')
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:12:17 +01:00
|
|
|
expect(output1).toBe(expected1)
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:12:17 +01:00
|
|
|
const output2 = content('tests/__data__/output/channels/ru.m3u')
|
|
|
|
const expected2 = content('tests/__data__/expected/channels/ru.m3u')
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:12:17 +01:00
|
|
|
expect(output2).toBe(expected2)
|
|
|
|
|
|
|
|
const output3 = content('tests/__data__/output/channels/uk.m3u')
|
|
|
|
const expected3 = content('tests/__data__/expected/channels/uk.m3u')
|
2021-12-12 05:13:02 +01:00
|
|
|
|
2022-02-05 06:12:17 +01:00
|
|
|
expect(output3).toBe(expected3)
|
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'
|
|
|
|
})
|
|
|
|
}
|