|
1 | 1 | // Implement a function repeatStr |
2 | 2 | const repeatStr = require("./repeat-str"); |
3 | | -// Given a target string `str` and a positive integer `count`, |
4 | | -// When the repeatStr function is called with these inputs, |
5 | | -// Then it should: |
6 | | - |
7 | | -// Case: handle multiple repetitions: |
8 | | -// Given a target string `str` and a positive integer `count` greater than 1, |
9 | | -// When the repeatStr function is called with these inputs, |
10 | | -// Then it should return a string that contains the original `str` repeated `count` times. |
11 | | - |
12 | | -/* |
13 | | -test("should repeat the string count times", () => { |
14 | | - const str = "hello"; |
15 | | - const count = 3; |
16 | | - const repeatedStr = repeatStr(str, count); |
17 | | - expect(repeatedStr).toEqual("hellohellohello"); |
18 | | -}); |
19 | | -*/ |
20 | | - |
21 | | -// Case: handle count of 1: |
22 | | -// Given a target string `str` and a `count` equal to 1, |
23 | | -// When the repeatStr function is called with these inputs, |
24 | | -// Then it should return the original `str` without repetition. |
25 | | - |
26 | | -// Case: Handle count of 0: |
27 | | -// Given a target string `str` and a `count` equal to 0, |
28 | | -// When the repeatStr function is called with these inputs, |
29 | | -// Then it should return an empty string. |
30 | | - |
31 | | -// Case: Handle negative count: |
32 | | -// Given a target string `str` and a negative integer `count`, |
33 | | -// When the repeatStr function is called with these inputs, |
34 | | -// Then it should throw an error, as negative counts are not valid. |
35 | 3 |
|
36 | 4 |
|
37 | 5 | describe("repeatStr", () => { |
|
0 commit comments