Skip to content

Commit

Permalink
Handle empty paramater conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Zabil Cheriya Maliackal <zabilcm@gmail.com>
  • Loading branch information
zabil committed Jul 1, 2024
1 parent 3dd1155 commit 329e896
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions e2e/specs/parameters.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Paramters

## Check parameter conversion

* Trimmed " " is the same as ""
9 changes: 9 additions & 0 deletions e2e/tests/parameter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as assert from "node:assert";
import { Step } from "gauge-ts";

export default class Parameter {
@Step("Trimmed <original> is the same as <expected>")
public async checkTrimmeWord(original: string, expected: string) {
assert.strictEqual(original.trim(), expected);
}
}
1 change: 1 addition & 0 deletions gauge-ts/src/processors/params/PrimitiveParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class PrimitiveParser implements ParameterParser {
}

private convertToNumber(value: string): number | undefined {
if (value.trim() === "") return undefined;
const num = Number(value);
return Number.isNaN(num) ? undefined : num;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 329e896

Please sign in to comment.