mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update editor.test.ts
This commit is contained in:
parent
74ce0a9a2e
commit
cd15eecd5f
1 changed files with 23 additions and 11 deletions
|
@ -3,6 +3,11 @@ import { execSync } from 'child_process'
|
|||
import os from 'os'
|
||||
import path from 'path'
|
||||
|
||||
type ExecError = {
|
||||
status: number
|
||||
stdout: string
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copySync(
|
||||
|
@ -18,17 +23,24 @@ describe('channels:editor', () => {
|
|||
ENV_VAR = 'SET "DATA_DIR=tests/__data__/input/temp/data" &&'
|
||||
}
|
||||
|
||||
const cmd = `${ENV_VAR} npm run channels:editor -- tests/__data__/output/channels.xml`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
|
||||
expect(stdout).toContain('CNN International | CNNInternational.us [new]')
|
||||
expect(stdout).toContain('CNN International Europe | CNNInternationalEurope.us [api]')
|
||||
expect(stdout).toContain('Overwrite')
|
||||
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-editor/channels-editor.channels.xml')
|
||||
)
|
||||
try {
|
||||
const cmd = `${ENV_VAR} npm run channels:editor -- tests/__data__/output/channels.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
} catch (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 [api]'
|
||||
)
|
||||
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-editor/channels-editor.channels.xml')
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue