Skip to content

Commit dee4647

Browse files
committed
Merge two tests into 1, and change test names to be more generic
1 parent 4abb6da commit dee4647

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

‎practice-tdd/repeat-str.test.js‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ import { repeatStr } from "./repeat-str.js";
99
// When the repeatStr function is called with these inputs,
1010
// Then it should return a string that contains the original `str` repeated `count` times.
1111

12-
test("should repeat the string count times, count is 3", () => {
13-
const str = "hello";
14-
const count = 3;
15-
const repeatedStr = repeatStr(str, count);
12+
test("should repeat the string count times", () => {
13+
let str = "hello";
14+
let count = 3;
15+
let repeatedStr = repeatStr(str, count);
1616
expect(repeatedStr).toEqual("hellohellohello");
17-
});
18-
19-
test("should repeat the string count times, count is 4", () => {
20-
const str = "hello";
21-
const count = 4;
22-
const repeatedStr = repeatStr(str, count);
17+
str = "hello";
18+
count = 4;
19+
repeatedStr = repeatStr(str, count);
2320
expect(repeatedStr).toEqual("hellohellohellohello");
2421
});
2522

26-
test("should repeat the string count times, count is 3, any string", () => {
23+
test("should repeat the string count times, any string", () => {
2724
const str = "Orb";
2825
const count = 3;
2926
const repeatedStr = repeatStr(str, count);
@@ -35,7 +32,7 @@ test("should repeat the string count times, count is 3, any string", () => {
3532
// When the repeatStr function is called with these inputs,
3633
// Then it should return the original `str` without repetition.
3734

38-
test("should repeat 'hello' 1 time", () => {
35+
test("should not repeat string when count is 1", () => {
3936
const str = "hello";
4037
const count = 1;
4138
const repeatedStr = repeatStr(str, count);
@@ -47,7 +44,7 @@ test("should repeat 'hello' 1 time", () => {
4744
// When the repeatStr function is called with these inputs,
4845
// Then it should return an empty string.
4946

50-
test("should return empty string, count is 0", () => {
47+
test("should return empty string when count is 0", () => {
5148
const str = "hello";
5249
const count = 0;
5350
const repeatedStr = repeatStr(str, count);
@@ -59,7 +56,7 @@ test("should return empty string, count is 0", () => {
5956
// When the repeatStr function is called with these inputs,
6057
// Then it should throw an error, as negative counts are not valid.
6158

62-
test("should throw error, count is negative", () => {
59+
test("should throw error when count is negative", () => {
6360
const str = "hello";
6461
const count = -1;
6562
expect(() => {

0 commit comments

Comments
 (0)