Skip to content

Commit

Permalink
Merge pull request #186 from getgauge/stringparameterconversion
Browse files Browse the repository at this point in the history
Handle empty parameter conversion
  • Loading branch information
zabil authored Jul 2, 2024
2 parents 3dd1155 + 5c752a1 commit a34fb72
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
4 changes: 0 additions & 4 deletions e2e/specs/example.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ Here's a step that takes a table
|Snap |1 |
|GoCD |1 |
|Rhythm|0 |

## Custom Parameters in steps

* This step uses a custom parameter of type Person and value "{\"name\":\"John\",\"age\":30}"
9 changes: 9 additions & 0 deletions e2e/specs/parameters.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Parameters

## Check parameter conversion

* Trimmed " " is the same as ""

## Custom Parameters in steps

* This step uses a custom parameter of type Person and value "{\"name\":\"John\",\"age\":30}"
8 changes: 0 additions & 8 deletions e2e/tests/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as assert from "node:assert";
import VowelCounter from "@lib/VowelCounter";
import { DataStoreFactory, Step, type Table } from "gauge-ts";

import type { Person } from "@lib/Person";

export default class Implementation {
static vowelsCount = (word: string): number => {
const counter = DataStoreFactory.getSpecDataStore().get(
Expand Down Expand Up @@ -36,10 +34,4 @@ export default class Implementation {
);
}
}
@Step("This step uses a custom parameter of type Person and value <person>")
public async validatePerson(person: Person) {
assert.strictEqual(person.name, "John");
assert.strictEqual(person.age, 30);
assert.ok(person.isAdult());
}
}
17 changes: 17 additions & 0 deletions e2e/tests/parameter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as assert from "node:assert";
import type { Person } from "@lib/Person";
import { Step } from "gauge-ts";

export default class Parameter {
@Step("Trimmed <original> is the same as <expected>")
public async checkTrimmedWord(original: string, expected: string) {
assert.strictEqual(original.trim(), expected);
}

@Step("This step uses a custom parameter of type Person and value <person>")
public async validatePerson(person: Person) {
assert.strictEqual(person.name, "John");
assert.strictEqual(person.age, 30);
assert.ok(person.isAdult());
}
}
2 changes: 1 addition & 1 deletion gauge-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gauge-ts",
"version": "0.3.3",
"version": "0.3.4",
"description": "Typescript runner for Gauge",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion gauge-ts/src/processors/params/PrimitiveParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PrimitiveParser implements ParameterParser {
}

private convertToNumber(value: string): number | undefined {
const num = Number(value);
const num = Number.parseFloat(value);
return Number.isNaN(num) ? undefined : num;
}

Expand Down
2 changes: 1 addition & 1 deletion gauge-ts/ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"linux": ["./launcher.mjs", "--start"],
"windows": ["launcher.bat", "--start"]
},
"version": "0.3.3",
"version": "0.3.4",
"gRPCSupport": true
}
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 a34fb72

Please sign in to comment.