We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12fb231 commit e296ae7Copy full SHA for e296ae7
1 file changed
Sprint-2/stretch/count-words.test.js
@@ -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