Files
epg/tests/commands/sites/update.test.ts

29 lines
795 B
TypeScript
Raw Normal View History

2025-01-01 10:48:16 +03:00
import { execSync } from 'child_process'
import fs from 'fs-extra'
import { pathToFileURL } from 'node:url'
2025-01-01 10:48:16 +03:00
const ENV_VAR = 'cross-env SITES_DIR=tests/__data__/input/sites_update/sites ROOT_DIR=tests/__data__/output'
2025-01-07 19:24:50 +03:00
2025-01-01 10:48:16 +03:00
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
})
it('can update SITES.md', () => {
2025-01-07 19:24:50 +03:00
const cmd = `${ENV_VAR} npm run sites:update`
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
2025-01-01 10:48:16 +03:00
2025-01-21 18:48:24 +03:00
expect(content('tests/__data__/output/SITES.md')).toEqual(
2025-04-02 07:12:46 +03:00
content('tests/__data__/expected/sites_update/SITES.md')
2025-01-01 10:48:16 +03:00
)
})
function content(filepath: string) {
const data = fs.readFileSync(pathToFileURL(filepath), {
2025-01-01 10:48:16 +03:00
encoding: 'utf8'
})
return JSON.stringify(data)
}