mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Create generate.test.ts
This commit is contained in:
parent
f90df54839
commit
9fb926f2f9
1 changed files with 31 additions and 0 deletions
31
tests/commands/api/generate.test.ts
Normal file
31
tests/commands/api/generate.test.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
|
||||
let ENV_VAR = 'SITES_DIR=tests/__data__/input/epg-grab/sites API_DIR=tests/__data__/output'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR =
|
||||
'SET "SITES_DIR=tests/__data__/input/epg-grab/sites" && SET "API_DIR=tests/__data__/output" &&'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
})
|
||||
|
||||
describe('api:generate', () => {
|
||||
it('can generate guides.json', () => {
|
||||
const cmd = `${ENV_VAR} npm run api:generate`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
|
||||
expect(content('tests/__data__/output/guides.json')).toEqual(
|
||||
content('tests/__data__/expected/guides.json')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue