From a01f59415469b341e8a55138798a99ace7d530ee Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sun, 22 Dec 2024 00:57:17 +0300 Subject: [PATCH] test: add `transformMarkdown` test --- test/cli.test.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/test/cli.test.js b/test/cli.test.js index ffecb34d4d..11b692affd 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -18,7 +18,7 @@ import { fileURLToPath } from 'node:url' import net from 'node:net' import getPort from 'get-port' import '../build/globals.js' -import { isMain, normalizeExt } from '../build/cli.js' +import { isMain, normalizeExt, transformMarkdown } from '../build/cli.js' const __filename = fileURLToPath(import.meta.url) const spawn = $.spawn @@ -283,12 +283,31 @@ describe('cli', () => { assert.ok(['EACCES', 'ENOENT'].includes(e.code)) } }) - }) - test('normalizeExt()', () => { - assert.equal(normalizeExt('.ts'), '.ts') - assert.equal(normalizeExt('ts'), '.ts') - assert.equal(normalizeExt('.'), '.') - assert.equal(normalizeExt(), undefined) + test('transformMarkdown()', () => { + // prettier-ignore + assert.equal(transformMarkdown(` +# Title + +~~~js +await $\`echo "tilde"\` +~~~ + +`), `// +// # Title +// + +await $\`echo "tilde"\` + +// +// `) + }) + + test('normalizeExt()', () => { + assert.equal(normalizeExt('.ts'), '.ts') + assert.equal(normalizeExt('ts'), '.ts') + assert.equal(normalizeExt('.'), '.') + assert.equal(normalizeExt(), undefined) + }) }) })