mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 18:37:17 -05:00
Update tests
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
|
||||
let ENV_VAR =
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/readme_update README_DIR=tests/__data__/output/.readme'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR =
|
||||
'SET "DATA_DIR=tests/__data__/input/data" && SET "LOGS_DIR=tests/__data__/input/readme_update" && SET "README_DIR=tests/__data__/output/.readme" &&'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
@@ -13,17 +21,18 @@ beforeEach(() => {
|
||||
'tests/__data__/input/readme_update/.readme/template.md',
|
||||
'tests/__data__/output/.readme/template.md'
|
||||
)
|
||||
|
||||
execSync(
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/readme_update README_DIR=tests/__data__/output/.readme npm run readme:update',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can update readme.md', () => {
|
||||
expect(content('tests/__data__/output/readme.md')).toEqual(
|
||||
content('tests/__data__/expected/readme_update/_readme.md')
|
||||
)
|
||||
describe('readme:update', () => {
|
||||
it('can update readme.md', () => {
|
||||
const cmd = `${ENV_VAR} npm run readme:update`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(content('tests/__data__/output/readme.md')).toEqual(
|
||||
content('tests/__data__/expected/readme_update/_readme.md')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
||||
Reference in New Issue
Block a user