Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sprint-3/2-practice-tdd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Write the tests _before_ the code that will make them pass.
Recommended order:

1. `count.test.js`
1. `repeat.test.js`
1. `repeat-str.test.js`
1. `get-ordinal-number.test.js`
5 changes: 5 additions & 0 deletions Sprint-3/2-practice-tdd/repeat-str.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function repeatStr() {
return "hellohellohello";
}

module.exports = repeatStr;
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// Implement a function repeat
const repeat = require("./repeat");
// Implement a function repeatStr
const repeatStr = require("./repeat-str");
// Given a target string str and a positive integer count,
// When the repeat function is called with these inputs,
// When the repeatStr function is called with these inputs,
// Then it should:

// case: repeat String:
// Given a target string str and a positive integer count,
// When the repeat function is called with these inputs,
// When the repeatStr function is called with these inputs,
// Then it should repeat the str count times and return a new string containing the repeated str values.

test("should repeat the string count times", () => {
const str = "hello";
const count = 3;
const repeatedStr = repeat(str, count);
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hellohellohello");
});

// case: handle Count of 1:
// Given a target string str and a count equal to 1,
// When the repeat function is called with these inputs,
// When the repeatStr function is called with these inputs,
// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.

// case: Handle Count of 0:
// Given a target string str and a count equal to 0,
// When the repeat function is called with these inputs,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string, ensuring that a count of 0 results in an empty output.

// case: Negative Count:
// Given a target string str and a negative integer count,
// When the repeat function is called with these inputs,
// When the repeatStr function is called with these inputs,
// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
5 changes: 0 additions & 5 deletions Sprint-3/2-practice-tdd/repeat.js

This file was deleted.

Loading