Files
iptv/tests/commands/api/generate.test.ts

26 lines
628 B
TypeScript
Raw Normal View History

2023-09-15 18:40:14 +03:00
import { execSync } from 'child_process'
import fs from 'fs-extra'
2022-02-13 01:40:45 +03:00
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
2025-03-29 11:39:30 +03:00
})
2022-02-13 01:40:45 +03:00
2025-03-29 11:39:30 +03:00
it('can create streams.json', () => {
2023-09-22 06:22:47 +03:00
execSync(
2025-03-29 11:39:30 +03:00
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/api_generate API_DIR=tests/__data__/output/.api npm run api:generate',
2022-02-13 01:40:45 +03:00
{ encoding: 'utf8' }
)
2025-03-29 11:39:30 +03:00
expect(content('output/.api/streams.json')).toMatchObject(
content('expected/api_generate/.api/streams.json')
)
2022-02-13 01:40:45 +03:00
})
2023-09-15 18:40:14 +03:00
function content(filepath: string) {
2022-08-10 03:41:21 +03:00
return JSON.parse(
fs.readFileSync(`tests/__data__/${filepath}`, {
encoding: 'utf8'
})
)
2022-02-13 01:40:45 +03:00
}