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

27 lines
676 B
JavaScript
Raw Normal View History

2022-01-09 20:14:41 +03:00
const { execSync } = require('child_process')
2022-02-26 23:21:44 +03:00
const fs = require('fs-extra')
const path = require('path')
2022-01-09 20:14:41 +03:00
beforeEach(() => {
2022-02-26 23:21:44 +03:00
fs.emptyDirSync('tests/__data__/output')
2022-01-09 20:14:41 +03:00
2022-01-29 23:16:35 +03:00
const stdout = execSync(
2022-04-16 23:05:53 +03:00
'CHANNELS_PATH=tests/__data__/input/sites/example.com_ca-*.channels.xml OUTPUT_DIR=tests/__data__/output/api npm run api:update',
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', () => {
2022-02-26 23:21:44 +03:00
expect(content('tests/__data__/output/api/guides.json')).toBe(
content('tests/__data__/expected/api/guides.json')
)
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)
}