mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Minor changes to the tests
This commit is contained in:
parent
e1ffd61618
commit
3c858ecca9
6 changed files with 24 additions and 21 deletions
|
@ -17,7 +17,7 @@ describe('api:generate', () => {
|
||||||
it('can generate guides.json', () => {
|
it('can generate guides.json', () => {
|
||||||
const cmd = `${ENV_VAR} npm run api:generate`
|
const cmd = `${ENV_VAR} npm run api:generate`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guides.json')).toEqual(
|
expect(content('tests/__data__/output/guides.json')).toEqual(
|
||||||
content('tests/__data__/expected/guides.json')
|
content('tests/__data__/expected/guides.json')
|
||||||
|
|
|
@ -8,6 +8,11 @@ type ExecError = {
|
||||||
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" &&'
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.copySync(
|
fs.copySync(
|
||||||
|
@ -18,16 +23,12 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('channels:editor', () => {
|
describe('channels:editor', () => {
|
||||||
it('shows list of options for a channel', () => {
|
it('shows list of options for a channel', () => {
|
||||||
let ENV_VAR = 'DATA_DIR=tests/__data__/input/temp/data'
|
|
||||||
if (os.platform() === 'win32') {
|
|
||||||
ENV_VAR = 'SET "DATA_DIR=tests/__data__/input/temp/data" &&'
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cmd = `${ENV_VAR} npm run channels:editor --- tests/__data__/output/channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:editor --- tests/__data__/output/channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||||
expect((error as ExecError).status).toBe(1)
|
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 | CNNInternational.us [new]')
|
||||||
expect((error as ExecError).stdout).toContain(
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe('channels:lint', () => {
|
||||||
try {
|
try {
|
||||||
const cmd = 'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml'
|
const cmd = 'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml'
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, 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)
|
||||||
|
@ -25,7 +25,7 @@ describe('channels:lint', () => {
|
||||||
const cmd =
|
const cmd =
|
||||||
'npm run channels:lint --- tests/__data__/input/channels-lint/invalid.channels.xml'
|
'npm run channels:lint --- tests/__data__/input/channels-lint/invalid.channels.xml'
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, 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)
|
||||||
|
@ -40,7 +40,7 @@ describe('channels:lint', () => {
|
||||||
const cmd =
|
const cmd =
|
||||||
'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml tests/__data__/input/channels-lint/invalid.channels.xml'
|
'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml tests/__data__/input/channels-lint/invalid.channels.xml'
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, 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)
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('channels:parse', () => {
|
||||||
const cmd =
|
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'
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
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')
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('channels:validate', () => {
|
||||||
try {
|
try {
|
||||||
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, 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)
|
||||||
|
@ -36,7 +36,7 @@ describe('channels:validate', () => {
|
||||||
try {
|
try {
|
||||||
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, 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)
|
||||||
|
|
|
@ -3,6 +3,13 @@ import fs from 'fs-extra'
|
||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
|
|
||||||
|
let ENV_VAR =
|
||||||
|
'DOT_SITES_DIR=tests/__data__/output/.sites SITES_DIR=tests/__data__/input/sites-update/sites'
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
ENV_VAR =
|
||||||
|
'SET "DOT_SITES_DIR=tests/__data__/output/.sites" && SET "SITES_DIR=tests/__data__/input/sites-update/sites" &&'
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.mkdirSync('tests/__data__/output/.sites')
|
fs.mkdirSync('tests/__data__/output/.sites')
|
||||||
|
@ -17,15 +24,10 @@ beforeEach(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can update SITES.md', () => {
|
it('can update SITES.md', () => {
|
||||||
let ENV_VAR =
|
const cmd = `${ENV_VAR} npm run sites:update`
|
||||||
'DOT_SITES_DIR=tests/__data__/output/.sites SITES_DIR=tests/__data__/input/sites-update/sites'
|
|
||||||
if (os.platform() === 'win32') {
|
|
||||||
ENV_VAR =
|
|
||||||
'SET "DOT_SITES_DIR=tests/__data__/output/.sites" && SET "SITES_DIR=tests/__data__/input/sites-update/sites" &&'
|
|
||||||
}
|
|
||||||
|
|
||||||
const stdout = execSync(`${ENV_VAR} npm run sites:update`, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
expect(content('tests/__data__/output/sites.md')).toEqual(
|
expect(content('tests/__data__/output/sites.md')).toEqual(
|
||||||
content('tests/__data__/expected/_sites.md')
|
content('tests/__data__/expected/_sites.md')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue