mirror of
https://github.com/iptv-org/epg
synced 2026-05-10 03:17:04 -04:00
Update tests
This commit is contained in:
@@ -2,20 +2,21 @@ import { execSync } from 'child_process'
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
|
|
||||||
const ENV_VAR = 'cross-env SITES_DIR=tests/__data__/input/api_generate/sites API_DIR=tests/__data__/output'
|
const ENV_VAR =
|
||||||
|
'cross-env SITES_DIR=tests/__data__/input/guides_export/sites API_DIR=tests/__data__/output'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('api:generate', () => {
|
describe('guides:export', () => {
|
||||||
it('can generate guides.json', () => {
|
it('can generate guides.json', () => {
|
||||||
const cmd = `${ENV_VAR} npm run api:generate`
|
const cmd = `${ENV_VAR} npm run guides:export`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, 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/api_generate/guides.json')
|
content('tests/__data__/expected/guides_export/guides.json')
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -2,14 +2,15 @@ import { execSync } from 'child_process'
|
|||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
const ENV_VAR = 'cross-env ROOT_DIR=tests/__data__/output'
|
const ENV_VAR =
|
||||||
|
'cross-env CURR_DATE=2022-10-04 ROOT_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/guides_update'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.copySync('tests/__data__/input/guides_update/workers.txt', 'tests/__data__/output/workers.txt')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can update GUIDES.md', () => {
|
describe('guides:update', () => {
|
||||||
|
it('can update GUIDES.md', () => {
|
||||||
const cmd = `${ENV_VAR} npm run guides:update`
|
const cmd = `${ENV_VAR} npm run guides:update`
|
||||||
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
@@ -18,6 +19,7 @@ it('can update GUIDES.md', () => {
|
|||||||
expect(content('tests/__data__/output/GUIDES.md')).toEqual(
|
expect(content('tests/__data__/output/GUIDES.md')).toEqual(
|
||||||
content('tests/__data__/expected/guides_update/GUIDES.md')
|
content('tests/__data__/expected/guides_update/GUIDES.md')
|
||||||
)
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath: string) {
|
function content(filepath: string) {
|
||||||
|
|||||||
32
tests/commands/workers/load.test.ts
Normal file
32
tests/commands/workers/load.test.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { execSync } from 'child_process'
|
||||||
|
import { pathToFileURL } from 'node:url'
|
||||||
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
|
const ENV_VAR =
|
||||||
|
'cross-env CURR_DATE=2022-10-04 ROOT_DIR=tests/__data__/output DATA_DIR=tests/__data__/output/'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
|
fs.copySync('tests/__data__/input/workers_load/workers.txt', 'tests/__data__/output/workers.txt')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('workers:load', () => {
|
||||||
|
it('can create workers.json', () => {
|
||||||
|
const cmd = `${ENV_VAR} npm run workers:load`
|
||||||
|
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
|
expect(content('tests/__data__/output/workers.json')).toEqual(
|
||||||
|
content('tests/__data__/expected/workers_load/workers.json')
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function content(filepath: string) {
|
||||||
|
const data = fs.readFileSync(pathToFileURL(filepath), {
|
||||||
|
encoding: 'utf8'
|
||||||
|
})
|
||||||
|
|
||||||
|
return JSON.stringify(data)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user