Skip to content

Commit e296ae7

Browse files
committed
Fix test file location for countWords
1 parent 12fb231 commit e296ae7

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const countWords = require("./count-words.js");
2+
3+
describe("countWords()", () => {
4+
test("counts repeated words", () => {
5+
expect(countWords("you and me and you")).toEqual({
6+
you: 2,
7+
and: 2,
8+
me: 1,
9+
});
10+
});
11+
12+
test("handles punctuation stuck to words", () => {
13+
expect(countWords("Hello,World! Hello World!")).toEqual({
14+
hello: 2,
15+
world: 2,
16+
});
17+
});
18+
19+
test("handles inherited-property words safely", () => {
20+
expect(countWords("constructor constructor")).toEqual({
21+
constructor: 2,
22+
});
23+
});
24+
25+
test("handles extra spaces correctly", () => {
26+
expect(countWords(" Hello World ")).toEqual({
27+
hello: 1,
28+
world: 1,
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)