mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Create update.test.ts
This commit is contained in:
parent
31463dcf39
commit
0c99219400
1 changed files with 36 additions and 0 deletions
36
tests/commands/sites/update.test.ts
Normal file
36
tests/commands/sites/update.test.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/output/.sites')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/.sites/config.json',
|
||||
'tests/__data__/output/.sites/config.json'
|
||||
)
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/.sites/template.md',
|
||||
'tests/__data__/output/.sites/template.md'
|
||||
)
|
||||
})
|
||||
|
||||
it('can update SITES.md', () => {
|
||||
const stdout = execSync('DOT_SITES_DIR=tests/__data__/output/.sites npm run sites:update', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
expect(content('tests/__data__/output/sites.md')).toEqual(
|
||||
content('tests/__data__/expected/_sites.md')
|
||||
)
|
||||
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue