Skip to content

Commit

Permalink
Fix tsconfig path loading bug and add tests
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 Jun 14, 2024
1 parent c7a59a7 commit f2a0650
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
3 changes: 2 additions & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"devDependencies": {
"@getgauge/cli": "latest",
"@types/node": "latest",
"taiko": "^1.4.0"
"taiko": "^1.4.0",
"tsconfig-paths": "^4.2.0"
}
}
17 changes: 17 additions & 0 deletions e2e/src/VowelCounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default class VowelCounter {
private vowels: string[];

constructor(vowels: string[]) {
this.vowels = vowels;
}

countVowels(word: string): number {
let count = 0;
for (const char of word) {
if (this.vowels.includes(char.toLowerCase())) {
count++;
}
}
return count;
}
}
14 changes: 9 additions & 5 deletions e2e/tests/implementation.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import * as assert from "node:assert";
import VowelCounter from "@lib/VowelCounter";
import { DataStoreFactory, Step, type Table } from "gauge-ts";

class Implementation {
static vowelsCount = (word: string): number => {
const vowels = DataStoreFactory.getSpecDataStore().get(
"vowels",
) as string[];
return word.split("").filter((c) => vowels.includes(c)).length;
const counter = DataStoreFactory.getSpecDataStore().get(
"counter",
) as VowelCounter;
return counter.countVowels(word);
};

@Step("Vowels in English language are <aeiou>.")
public async listVowels(vowels: string) {
DataStoreFactory.getSpecDataStore().put("vowels", vowels.split(""));
DataStoreFactory.getSpecDataStore().put(
"counter",
new VowelCounter(vowels.split("")),
);
}

@Step("The word <gauge> has <3> vowels.")
Expand Down
5 changes: 4 additions & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"strict": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
"emitDecoratorMetadata": true,
"paths": {
"@lib/*": ["./src/*"]
}
},
"include": ["tests/**/*", "gen/**/*"],
"exclude": ["node_modules/"]
Expand Down
3 changes: 3 additions & 0 deletions gauge-ts/launcher.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env node

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

const version = process.versions.node.split(".");
if (Number.parseInt(version[0]) < 20) {
throw new Error(
Expand Down
30 changes: 27 additions & 3 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 f2a0650

Please sign in to comment.