Fixes linter errors

This commit is contained in:
freearhey 2023-10-15 14:08:23 +03:00
parent 57e508fc3b
commit 63c86a2b30
393 changed files with 28447 additions and 28443 deletions

View file

@ -1,51 +1,51 @@
import fs from 'fs-extra'
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(
'tests/__data__/input/channels-editor/channels-editor.channels.xml',
'tests/__data__/output/channels.xml'
)
})
describe('channels:editor', () => {
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 {
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')
)
}
})
})
function content(filepath: string) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
})
}
import fs from 'fs-extra'
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(
'tests/__data__/input/channels-editor/channels-editor.channels.xml',
'tests/__data__/output/channels.xml'
)
})
describe('channels:editor', () => {
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 {
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')
)
}
})
})
function content(filepath: string) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
})
}

View file

@ -1,22 +1,22 @@
import { execSync } from 'child_process'
type ExecError = {
status: number
stdout: string
}
describe('channels:lint', () => {
it('will show a message if the file contains a syntax error', () => {
try {
const cmd =
'npm run channels:lint -- --channels=tests/__data__/input/channels-lint/channels-lint.channels.xml'
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(
"channels-lint.channels.xml\n 3:0 Element 'channel': The attribute 'lang' is required but missing.\n\n1 error(s)\n"
)
}
})
})
import { execSync } from 'child_process'
type ExecError = {
status: number
stdout: string
}
describe('channels:lint', () => {
it('will show a message if the file contains a syntax error', () => {
try {
const cmd =
'npm run channels:lint -- --channels=tests/__data__/input/channels-lint/channels-lint.channels.xml'
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(
"channels-lint.channels.xml\n 3:0 Element 'channel': The attribute 'lang' is required but missing.\n\n1 error(s)\n"
)
}
})
})

View file

@ -1,39 +1,39 @@
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync(
'tests/__data__/input/channels-parse/channels-parse.channels.xml',
'tests/__data__/output/channels.xml'
)
})
describe('channels:parse', () => {
it('can parse channels', () => {
const cmd =
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml'
execSync(cmd, { encoding: 'utf8' })
expect(content('tests/__data__/output/channels.xml')).toEqual(
content('tests/__data__/expected/sites/channels-parse/channels-parse.channels.xml')
)
})
it('can parse channels with clean flag', () => {
const cmd =
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml --clean'
execSync(cmd, { encoding: 'utf8' })
expect(content('tests/__data__/output/channels.xml')).toEqual(
content('tests/__data__/expected/sites/channels-parse/channels-parse-clean.channels.xml')
)
})
})
function content(filepath: string) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
})
}
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync(
'tests/__data__/input/channels-parse/channels-parse.channels.xml',
'tests/__data__/output/channels.xml'
)
})
describe('channels:parse', () => {
it('can parse channels', () => {
const cmd =
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml'
execSync(cmd, { encoding: 'utf8' })
expect(content('tests/__data__/output/channels.xml')).toEqual(
content('tests/__data__/expected/sites/channels-parse/channels-parse.channels.xml')
)
})
it('can parse channels with clean flag', () => {
const cmd =
'npm run channels:parse -- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml --clean'
execSync(cmd, { encoding: 'utf8' })
expect(content('tests/__data__/output/channels.xml')).toEqual(
content('tests/__data__/expected/sites/channels-parse/channels-parse-clean.channels.xml')
)
})
})
function content(filepath: string) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
})
}

View file

@ -1,48 +1,48 @@
import { execSync } from 'child_process'
import os from 'os'
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" &&'
}
describe('channels:validate', () => {
it('will show a message if the file contains a duplicate', () => {
try {
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(`duplicate.channels.xml
(index) type lang xmltv_id site_id name
0 'duplicate' 'en' 'BravoEast.us' '140' 'Bravo'
\n1 error(s) in 1 file(s)\n`)
}
})
it('will show a message if the file contains a channel with wrong xmltv_id', () => {
try {
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(`wrong_xmltv_id.channels.xml
(index) type lang xmltv_id site_id name
0 'wrong_xmltv_id' 'en' 'CNNInternational' '140' 'CNN International'
\n1 error(s) in 1 file(s)\n`)
}
})
})
import { execSync } from 'child_process'
import os from 'os'
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" &&'
}
describe('channels:validate', () => {
it('will show a message if the file contains a duplicate', () => {
try {
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(`duplicate.channels.xml
(index) type lang xmltv_id site_id name
0 'duplicate' 'en' 'BravoEast.us' '140' 'Bravo'
\n1 error(s) in 1 file(s)\n`)
}
})
it('will show a message if the file contains a channel with wrong xmltv_id', () => {
try {
const cmd = `${ENV_VAR} npm run channels:validate -- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
execSync(cmd, { encoding: 'utf8' })
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(`wrong_xmltv_id.channels.xml
(index) type lang xmltv_id site_id name
0 'wrong_xmltv_id' 'en' 'CNNInternational' '140' 'CNN International'
\n1 error(s) in 1 file(s)\n`)
}
})
})