From cea1e222103d732785177603957e5d3e930a9c12 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 21 Nov 2024 10:41:20 -0800 Subject: [PATCH] rename example formatter in comments --- src/cucumber-runner.ts | 12 ++++++------ tests/unit/src/cucumber-runner.spec.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cucumber-runner.ts b/src/cucumber-runner.ts index bbf4171..fb1e7cd 100644 --- a/src/cucumber-runner.ts +++ b/src/cucumber-runner.ts @@ -68,13 +68,13 @@ export function buildArgs(runCfg: CucumberRunnerConfig, cucumberBin: string) { * * For structured inputs (`key:value` or `"key:value"`), returns a string in the * form `"key":"value"`, with the asset directory prepended to relative paths. - * For simple inputs (e.g., `progress-bar`), returns the input as-is. + * For simple inputs (e.g., `usage`), returns the input as-is. * * @param {string} format - The input format string. Examples include: * - `"key:value"` * - `"key":"value"` * - `key:value` - * - `progress-bar` + * - `usage` * @param {string} assetDir - The directory to prepend to the value for relative paths. * @returns {string} The normalized format string. For structured inputs, it returns * a string in the form `"key":"value"`. For simple inputs, it @@ -83,8 +83,8 @@ export function buildArgs(runCfg: CucumberRunnerConfig, cucumberBin: string) { * Example: * - Input: `"html":"formatter/report.html"`, `"/project/assets"` * Output: `"html":"/project/assets/formatter/report.html"` - * - Input: `"progress-bar"`, `"/project/assets"` - * Output: `"progress-bar"` + * - Input: `"usage"`, `"/project/assets"` + * Output: `"usage"` */ export function normalizeFormat(format: string, assetDir: string): string { // Checks if the format is structured; if not, returns it unchanged. @@ -94,8 +94,8 @@ export function normalizeFormat(format: string, assetDir: string): string { } let [, key, value] = match; - key = key.replace(/^"|"$/g, ''); - value = value.replace(/^"|"$/g, ''); + key = key.replaceAll('"', ''); + value = value.replaceAll('"', ''); const updatedPath = path.join(assetDir, value); return `"${key}":"${updatedPath}"`; } diff --git a/tests/unit/src/cucumber-runner.spec.js b/tests/unit/src/cucumber-runner.spec.js index ce530f4..10a04ee 100644 --- a/tests/unit/src/cucumber-runner.spec.js +++ b/tests/unit/src/cucumber-runner.spec.js @@ -55,7 +55,7 @@ describe('normalizeFormat', () => { }); it('should return simple strings as-is', () => { - expect(normalizeFormat(`"progress-bar"`, assetDir)).toBe('"progress-bar"'); - expect(normalizeFormat(`progress-bar`, assetDir)).toBe('progress-bar'); + expect(normalizeFormat(`"usage"`, assetDir)).toBe('"usage"'); + expect(normalizeFormat(`usage`, assetDir)).toBe('usage'); }); });