Skip to content

Commit

Permalink
rename example formatter in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Nov 21, 2024
1 parent 1185713 commit cea1e22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/cucumber-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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}"`;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/src/cucumber-runner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

0 comments on commit cea1e22

Please sign in to comment.