iptv/tests/commands/update-readme.test.js

27 lines
700 B
JavaScript
Raw Normal View History

2022-02-07 06:39:55 +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-07 06:39:55 +01:00
fs.emptyDirSync('tests/__data__/output')
const stdout = execSync(
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs/generators node scripts/commands/update-readme.js --config=tests/__data__/input/_readme.json',
{ encoding: 'utf8' }
)
2021-12-12 05:13:02 +01:00
})
it('can update readme.md', () => {
2022-02-07 06:39:55 +01:00
expect(content('tests/__data__/output/readme.md')).toEqual(
content('tests/__data__/expected/_readme.md')
2021-12-12 05:13:02 +01:00
)
2022-02-07 06:39:55 +01:00
})
2021-12-12 05:13:02 +01:00
2022-02-07 06:39:55 +01:00
function content(filepath) {
const data = fs.readFileSync(path.resolve(filepath), {
2021-12-12 05:13:02 +01:00
encoding: 'utf8'
})
2022-02-07 06:39:55 +01:00
return JSON.stringify(data)
}