2022-01-09 20:14:41 +03:00
|
|
|
const { execSync } = require('child_process')
|
2022-02-26 23:21:44 +03:00
|
|
|
const fs = require('fs-extra')
|
|
|
|
|
const path = require('path')
|
2022-01-09 20:14:41 +03:00
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-02-26 23:21:44 +03:00
|
|
|
fs.emptyDirSync('tests/__data__/output')
|
2022-01-09 20:14:41 +03:00
|
|
|
|
2022-01-29 23:16:35 +03:00
|
|
|
const stdout = execSync(
|
2022-10-26 04:41:28 +03:00
|
|
|
'LOGS_DIR=tests/__data__/input/logs OUTPUT_DIR=tests/__data__/output/api npm run api:update',
|
2022-01-09 20:14:41 +03:00
|
|
|
{ encoding: 'utf8' }
|
|
|
|
|
)
|
2022-01-10 00:34:05 +03:00
|
|
|
})
|
|
|
|
|
|
2022-01-29 23:16:35 +03:00
|
|
|
it('can generate guides.json', () => {
|
2022-02-26 23:21:44 +03:00
|
|
|
expect(content('tests/__data__/output/api/guides.json')).toBe(
|
|
|
|
|
content('tests/__data__/expected/api/guides.json')
|
|
|
|
|
)
|
2022-01-09 20:14:41 +03:00
|
|
|
})
|
2022-01-09 20:29:18 +03:00
|
|
|
|
2022-01-10 00:34:05 +03:00
|
|
|
function content(filepath) {
|
|
|
|
|
const data = fs.readFileSync(path.resolve(filepath), {
|
2022-01-09 20:29:18 +03:00
|
|
|
encoding: 'utf8'
|
|
|
|
|
})
|
2022-01-10 00:34:05 +03:00
|
|
|
|
|
|
|
|
return JSON.stringify(data)
|
|
|
|
|
}
|