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/update-playlists.test.js

37 lines
1.0 KiB
JavaScript

const fs = require('fs-extra')
3 years ago
const path = require('path')
const { execSync } = require('child_process')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/temp')
fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db')
3 years ago
const stdout = execSync(
'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/update-playlists.js',
{ encoding: 'utf8' }
)
3 years ago
})
it('can update playlist', () => {
const output1 = content('tests/__data__/output/channels/ad.m3u')
const expected1 = content('tests/__data__/expected/channels/ad.m3u')
3 years ago
expect(output1).toBe(expected1)
3 years ago
const output2 = content('tests/__data__/output/channels/ru.m3u')
const expected2 = content('tests/__data__/expected/channels/ru.m3u')
3 years ago
expect(output2).toBe(expected2)
const output3 = content('tests/__data__/output/channels/uk.m3u')
const expected3 = content('tests/__data__/expected/channels/uk.m3u')
3 years ago
expect(output3).toBe(expected3)
3 years ago
})
function content(filepath) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
})
}