Files
epg/tests/commands/update-api.test.js

29 lines
776 B
JavaScript
Raw Normal View History

2022-01-09 20:14:41 +03:00
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
beforeEach(() => {
fs.rmdirSync('tests/__data__/output', { recursive: true })
fs.mkdirSync('tests/__data__/output')
2022-01-29 23:16:35 +03:00
const stdout = execSync(
2022-02-03 21:02:18 +03:00
'CHANNELS_PATH=tests/__data__/input/sites/**.channels.xml OUTPUT_DIR=tests/__data__/output/api node scripts/commands/update-api.js',
2022-01-09 20:14:41 +03:00
{ encoding: 'utf8' }
)
2022-01-10 00:34:05 +03:00
})
2022-01-29 23:16:35 +03:00
it('can generate guides.json', () => {
const output = content('tests/__data__/output/api/guides.json')
const expected = content('tests/__data__/expected/api/guides.json')
2022-01-10 00:34:05 +03:00
expect(output).toBe(expected)
2022-01-09 20:14:41 +03:00
})
2022-01-09 20:29:18 +03:00
2022-01-10 00:34:05 +03:00
function content(filepath) {
const data = fs.readFileSync(path.resolve(filepath), {
2022-01-09 20:29:18 +03:00
encoding: 'utf8'
})
2022-01-10 00:34:05 +03:00
return JSON.stringify(data)
}