-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.test.mjs
More file actions
31 lines (23 loc) · 897 Bytes
/
common.test.mjs
File metadata and controls
31 lines (23 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { getWordsToCheck, isCorrectWord, addingWords } from "./common.mjs";
import assert from "node:assert";
import {test, describe}from "node:test";
describe("SPell CHecker Logic", () => {
test("Should split the text and remove special characters", () => {
const input = "hello-world?";
const expectedResult = ["hello", "world"];
const result = getWordsToCheck(input);
assert.deepStrictEqual(result, expectedResult);
});
test("Should check if the first letter upperCase or lowerCase", () => {
const input = "Hello";
const result = isCorrectWord(input);
assert.strictEqual(result, true);
});
test("Should push the new words to the dictionary", () => {
const input = "hi";
assert.strictEqual(isCorrectWord(input), false);
addingWords(input);
const afterCheck = isCorrectWord(input);
assert.strictEqual(afterCheck, true);
});
});