diff --git a/e2e/specs/parameters.spec b/e2e/specs/parameters.spec new file mode 100644 index 0000000..53dc922 --- /dev/null +++ b/e2e/specs/parameters.spec @@ -0,0 +1,5 @@ +# Paramters + +## Check parameter conversion + +* Trimmed " " is the same as "" diff --git a/e2e/tests/parameter.ts b/e2e/tests/parameter.ts new file mode 100644 index 0000000..1bdb48f --- /dev/null +++ b/e2e/tests/parameter.ts @@ -0,0 +1,9 @@ +import * as assert from "node:assert"; +import { Step } from "gauge-ts"; + +export default class Parameter { + @Step("Trimmed is the same as ") + public async checkTrimmeWord(original: string, expected: string) { + assert.strictEqual(original.trim(), expected); + } +} diff --git a/gauge-ts/src/processors/params/PrimitiveParser.ts b/gauge-ts/src/processors/params/PrimitiveParser.ts index 958a176..d6de84c 100644 --- a/gauge-ts/src/processors/params/PrimitiveParser.ts +++ b/gauge-ts/src/processors/params/PrimitiveParser.ts @@ -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; } diff --git a/package-lock.json b/package-lock.json index 5e3bbef..485f36f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,8 +22,8 @@ "typescript": "^5.4.5" }, "devDependencies": { - "@getgauge/cli": "*", - "@types/node": "*", + "@getgauge/cli": "latest", + "@types/node": "latest", "taiko": "^1.4.0", "tsconfig-paths": "^4.2.0" }