From 2ac41ec8cd48e5da2b3098413b917da691ca8392 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 13 Feb 2026 12:51:24 +0300 Subject: [PATCH] Create update.test.ts --- tests/commands/guides/update.test.ts | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/commands/guides/update.test.ts diff --git a/tests/commands/guides/update.test.ts b/tests/commands/guides/update.test.ts new file mode 100644 index 00000000..4f3d0f6e --- /dev/null +++ b/tests/commands/guides/update.test.ts @@ -0,0 +1,29 @@ +import { execSync } from 'child_process' +import { pathToFileURL } from 'node:url' +import fs from 'fs-extra' + +const ENV_VAR = 'cross-env ROOT_DIR=tests/__data__/output' + +beforeEach(() => { + fs.emptyDirSync('tests/__data__/output') + fs.copySync('tests/__data__/input/guides_update/workers.txt', 'tests/__data__/output/workers.txt') +}) + +it('can update GUIDES.md', () => { + const cmd = `${ENV_VAR} npm run guides:update` + + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + + expect(content('tests/__data__/output/GUIDES.md')).toEqual( + content('tests/__data__/expected/guides_update/GUIDES.md') + ) +}) + +function content(filepath: string) { + const data = fs.readFileSync(pathToFileURL(filepath), { + encoding: 'utf8' + }) + + return JSON.stringify(data) +}