Skip to content

Commit 7f77ed1

Browse files
solve excersise count.test.js
1 parent 038bb6a commit 7f77ed1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎practice-tdd/count.test.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// implement a function countChar that counts the number of times a character occurs in a string
22
import { countChar } from "./count.js";
3+
import { test, expect } from "@jest/globals";
4+
35
// Given a string `str` and a single character `char` to search for,
46
// When the countChar function is called with these inputs,
57
// Then it should:
@@ -22,3 +24,10 @@ test("should count multiple occurrences of a character", () => {
2224
// And a character `char` that does not exist within `str`.
2325
// When the function is called with these inputs,
2426
// Then it should return 0, indicating that no occurrences of `char` were found.
27+
28+
test("should indicate no occurrences of a character", () => {
29+
const str = "abcde";
30+
const char = "f";
31+
const numberOfOcurrence = countChar(str, char);
32+
expect(numberOfOcurrence).toEqual(0);
33+
});

0 commit comments

Comments
 (0)