Create subfolders for commands
This commit is contained in:
29
tests/commands/playlist/update.test.js
Normal file
29
tests/commands/playlist/update.test.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/output/streams.db')
|
||||
|
||||
const stdout = execSync('DB_DIR=tests/__data__/output node scripts/commands/playlist/update.js', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can update playlists', () => {
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/channels/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user