mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update tests
This commit is contained in:
parent
0c0cc2af93
commit
f3ba9fbcfe
4 changed files with 27 additions and 35 deletions
|
@ -1,5 +1,6 @@
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
|
import os from 'os'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
|
@ -11,12 +12,13 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('channels:editor', () => {
|
describe('channels:editor', () => {
|
||||||
it('shows list of options for a channel', () => {
|
it('shows list of options for a channel', () => {
|
||||||
const stdout = execSync(
|
let ENV_VAR = 'DATA_DIR=tests/__data__/input/temp/data'
|
||||||
'DATA_DIR=tests/__data__/input/temp/data npm run channels:editor -- tests/__data__/output/channels.xml',
|
if (os.platform() === 'win32') {
|
||||||
{
|
ENV_VAR = 'SET "DATA_DIR=tests/__data__/input/temp/data" &&'
|
||||||
encoding: 'utf8'
|
}
|
||||||
}
|
|
||||||
)
|
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 | CNNInternational.us [new]')
|
||||||
expect(stdout).toContain('CNN International Europe | CNNInternationalEurope.us [api]')
|
expect(stdout).toContain('CNN International Europe | CNNInternationalEurope.us [api]')
|
||||||
|
|
|
@ -8,13 +8,9 @@ type ExecError = {
|
||||||
describe('channels:lint', () => {
|
describe('channels:lint', () => {
|
||||||
it('will show a message if the file contains a syntax error', () => {
|
it('will show a message if the file contains a syntax error', () => {
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(
|
const cmd =
|
||||||
'npm run channels:lint -- --channels=tests/__data__/input/channels-lint/channels-lint.channels.xml',
|
'npm run channels:lint -- --channels=tests/__data__/input/channels-lint/channels-lint.channels.xml'
|
||||||
{
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
encoding: 'utf8'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log(stdout)
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect((error as ExecError).status).toBe(1)
|
expect((error as ExecError).status).toBe(1)
|
||||||
|
|
|
@ -12,10 +12,9 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('channels:parse', () => {
|
describe('channels:parse', () => {
|
||||||
it('can parse channels', () => {
|
it('can parse channels', () => {
|
||||||
execSync(
|
const cmd =
|
||||||
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml',
|
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml'
|
||||||
{ encoding: 'utf8' }
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
)
|
|
||||||
|
|
||||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||||
content('tests/__data__/expected/sites/channels-parse/channels-parse.channels.xml')
|
content('tests/__data__/expected/sites/channels-parse/channels-parse.channels.xml')
|
||||||
|
@ -23,10 +22,9 @@ describe('channels:parse', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse channels with clean flag', () => {
|
it('can parse channels with clean flag', () => {
|
||||||
execSync(
|
const cmd =
|
||||||
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml --clean',
|
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml --clean'
|
||||||
{ encoding: 'utf8' }
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
)
|
|
||||||
|
|
||||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||||
content('tests/__data__/expected/sites/channels-parse/channels-parse-clean.channels.xml')
|
content('tests/__data__/expected/sites/channels-parse/channels-parse-clean.channels.xml')
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
|
import os from 'os'
|
||||||
|
|
||||||
type ExecError = {
|
type ExecError = {
|
||||||
status: number
|
status: number
|
||||||
stdout: string
|
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" &&'
|
||||||
|
}
|
||||||
|
|
||||||
describe('channels:validate', () => {
|
describe('channels:validate', () => {
|
||||||
it('will show a message if the file contains a duplicate', () => {
|
it('will show a message if the file contains a duplicate', () => {
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(
|
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
|
||||||
'DATA_DIR=tests/__data__/input/temp/data npm run channels:validate -- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml',
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
{
|
|
||||||
encoding: 'utf8'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log(stdout)
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect((error as ExecError).status).toBe(1)
|
expect((error as ExecError).status).toBe(1)
|
||||||
|
@ -33,13 +34,8 @@ describe('channels:validate', () => {
|
||||||
|
|
||||||
it('will show a message if the file contains a channel with wrong xmltv_id', () => {
|
it('will show a message if the file contains a channel with wrong xmltv_id', () => {
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(
|
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
|
||||||
'DATA_DIR=tests/__data__/input/temp/data npm run channels:validate -- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml',
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
{
|
|
||||||
encoding: 'utf8'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log(stdout)
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect((error as ExecError).status).toBe(1)
|
expect((error as ExecError).status).toBe(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue