2025-04-22 23:17:48 +03:00
|
|
|
import { pathToFileURL } from 'node:url'
|
2023-09-15 18:40:14 +03:00
|
|
|
import { execSync } from 'child_process'
|
|
|
|
|
import fs from 'fs-extra'
|
2025-04-22 03:47:28 +03:00
|
|
|
|
2025-08-24 22:42:59 +03:00
|
|
|
const ENV_VAR =
|
|
|
|
|
'cross-env DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/readme_update ROOT_DIR=tests/__data__/output'
|
2023-09-15 18:40:14 +03:00
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
fs.emptyDirSync('tests/__data__/output')
|
|
|
|
|
})
|
|
|
|
|
|
2025-04-22 03:47:28 +03:00
|
|
|
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)
|
|
|
|
|
|
2025-08-24 22:42:59 +03:00
|
|
|
expect(content('tests/__data__/output/PLAYLISTS.md')).toEqual(
|
2025-09-02 17:00:50 +00:00
|
|
|
content('tests/__data__/expected/readme_update/playlists.md')
|
2025-04-22 03:47:28 +03:00
|
|
|
)
|
|
|
|
|
})
|
2023-09-15 18:40:14 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function content(filepath: string) {
|
2025-04-22 23:17:48 +03:00
|
|
|
return JSON.stringify(fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' }))
|
2023-09-15 18:40:14 +03:00
|
|
|
}
|