Skip to content

Commit ee15295

Browse files
committed
fixed test and code and added import node test and assert
1 parent 81c665a commit ee15295

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎practice-tdd/count.test.js‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// implement a function countChar that counts the number of times a character occurs in a string
2+
import { test } from "node:test";
3+
import { strict as assert } from "node:assert";
24
import { countChar } from "./count.js";
35
// Given a string `str` and a single character `char` to search for,
46
// When the countChar function is called with these inputs,
@@ -14,7 +16,7 @@ test("should count multiple occurrences of a character", () => {
1416
const str = "aaaaa";
1517
const char = "a";
1618
const count = countChar(str, char);
17-
expect(count).toEqual(5);
19+
assert.equal(count, 5);
1820
});
1921

2022
// Scenario: No Occurrences
@@ -27,5 +29,12 @@ test("should return 0 when there are no occurrences of a character", () => {
2729
const str = "hello";
2830
const char = "z";
2931
const count = countChar(str, char);
30-
expect(count).toEqual(0);
32+
assert.equal(count, 0);
33+
});
34+
35+
test("should return 0 when the string is empty", () => {
36+
const str = "";
37+
const char = "a";
38+
const count = countChar(str, char);
39+
assert.equal(count, 0);
3140
});

0 commit comments

Comments
 (0)