first commit
This commit is contained in:
8
src/main.ts
Normal file
8
src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { startREPL } from "./repl.js"
|
||||
|
||||
function main() {
|
||||
startREPL();
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
21
src/repl.test.ts
Normal file
21
src/repl.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { cleanInput } from "./repl.ts";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
describe.each([
|
||||
{
|
||||
input: " hello world ",
|
||||
expected: ["hello", "world"],
|
||||
},
|
||||
{
|
||||
input: " This is a Test ",
|
||||
expected: ["this", "is", "a", "test"],
|
||||
}
|
||||
])("cleanInput($input)", ({ input, expected }) => {
|
||||
test(`Expected: ${expected}`, () => {
|
||||
const actual = cleanInput(input);
|
||||
expect(actual).toHaveLength(expected.length);
|
||||
for (const i in expected) {
|
||||
expect(actual[i]).toBe(expected[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
4
src/repl.ts
Normal file
4
src/repl.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export function cleanInput(input: string): string[] {
|
||||
const lowercaseString = input.toLowerCase();
|
||||
return lowercaseString.trim().split(" ");
|
||||
}
|
||||
Reference in New Issue
Block a user