Create validate.test.js

This commit is contained in:
Aleksandr Statciuk 2023-01-08 09:59:29 +03:00
parent 1dd2a55cfd
commit f43944793f
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
const { execSync } = require('child_process')
const fs = require('fs-extra')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copyFileSync(
'tests/__data__/input/database/update-guides/programs.db',
'tests/__data__/output/programs.db'
)
})
it('will show a message if the channel is not in the guide', () => {
const stdout = execSync(
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/input/logs DATA_DIR=tests/__data__/input/data npm run guides:validate',
{
encoding: 'utf8'
}
)
expect(stdout).toBe(
`\n> guides:validate\n> node scripts/commands/guides/validate.js
loading data/channels.json...
loading tests/__data__/input/logs/guides/update.log...
loading database/programs.db...
found 4 programs
(index) type site lang xmltv_id broadcast_area languages
0 'no_guide' 'virginmedia.com' 'en' 'BBCNews.uk' [ 'c/UK' ] [ 'eng' ]
1 'no_guide' 'sky.com' 'en' 'BBCNews.uk' [ 'c/UK' ] [ 'eng' ]
2 error(s)
`
)
})