You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iptv/tests/commands/api/generate.test.ts

24 lines
591 B
TypeScript

import { execSync } from 'child_process'
import fs from 'fs-extra'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
const stdout = execSync(
'STREAMS_DIR=tests/__data__/input/streams_generate API_DIR=tests/__data__/output/.api npm run api:generate',
{ encoding: 'utf8' }
)
})
it('can create streams.json', () => {
expect(content(`output/.api/streams.json`)).toMatchObject(content(`expected/.api/streams.json`))
})
function content(filepath: string) {
return JSON.parse(
fs.readFileSync(`tests/__data__/${filepath}`, {
encoding: 'utf8'
})
)
}