mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Update edit.test.ts
This commit is contained in:
parent
8cdff31159
commit
bc4b5bd187
1 changed files with 10 additions and 25 deletions
|
@ -3,11 +3,6 @@ import { execSync } from 'child_process'
|
|||
import os from 'os'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
type ExecError = {
|
||||
status: number
|
||||
stdout: string
|
||||
}
|
||||
|
||||
let ENV_VAR = 'DATA_DIR=tests/__data__/input/temp/data'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR = 'SET "DATA_DIR=tests/__data__/input/temp/data" &&'
|
||||
|
@ -23,26 +18,16 @@ beforeEach(() => {
|
|||
|
||||
describe('channels:edit', () => {
|
||||
it('shows list of options for a channel', () => {
|
||||
try {
|
||||
const cmd = `${ENV_VAR} npm run channels:edit --- tests/__data__/output/channels.xml`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
} catch (error) {
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
expect((error as ExecError).stdout).toContain('CNN International | CNNInternational.us [new]')
|
||||
expect((error as ExecError).stdout).toContain(
|
||||
'CNN International Europe | CNNInternationalEurope.us'
|
||||
)
|
||||
expect((error as ExecError).stdout).toContain('Overwrite')
|
||||
expect((error as ExecError).stdout).toContain('Skip')
|
||||
expect((error as ExecError).stdout).toContain(
|
||||
"File 'tests/__data__/output/channels.xml' successfully saved"
|
||||
)
|
||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/sites/channels-edit/example.com.channels.xml')
|
||||
)
|
||||
}
|
||||
const cmd = `${ENV_VAR} npm run channels:edit --- tests/__data__/output/channels.xml`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
expect(stdout).toContain('CNN International Europe | CNNInternationalEurope.us')
|
||||
expect(stdout).toContain('Type...')
|
||||
expect(stdout).toContain('Skip')
|
||||
expect(stdout).toContain("File 'tests/__data__/output/channels.xml' successfully saved")
|
||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/sites/channels-edit/example.com.channels.xml')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue