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

27 lines
700 B
JavaScript
Raw Normal View History

2022-02-11 19:07:16 +01:00
const { execSync } = require('child_process')
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')
beforeEach(() => {
2022-02-07 06:39:55 +01:00
fs.emptyDirSync('tests/__data__/output')
const stdout = execSync(
2022-02-11 19:07:16 +01:00
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs/generators node scripts/commands/readme/update.js --config=tests/__data__/input/_readme.json',
2022-02-07 06:39:55 +01:00
{ 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)
}