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

29 lines
760 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')
2022-08-15 02:22:01 +03:00
fs.mkdirSync('tests/__data__/output/database')
2022-02-13 01:40:45 +03:00
fs.copyFileSync(
2023-04-28 17:07:32 +03:00
'tests/__data__/input/database/api_generate.streams.db',
2022-08-15 02:22:01 +03:00
'tests/__data__/output/database/streams.db'
2022-02-13 01:40:45 +03:00
)
const stdout = execSync(
2023-09-15 18:40:14 +03:00
'DB_DIR=tests/__data__/output/database API_DIR=tests/__data__/output/.api npm run api:generate',
2022-02-13 01:40:45 +03:00
{ encoding: 'utf8' }
)
})
it('can create streams.json', () => {
2023-04-27 17:41:38 +03:00
expect(content(`output/.api/streams.json`)).toMatchObject(content(`expected/.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
}