|
1 | | -const repeatString = require('./repeatString') |
| 1 | +const repeatString = require("./repeatString"); |
2 | 2 |
|
3 | | -describe('repeatString', function() { |
4 | | - it('repeats the string', function() { |
5 | | - expect(repeatString('hey', 3)).toEqual('heyheyhey'); |
6 | | - }); |
7 | | - xit('repeats the string many times', function() { |
8 | | - expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey'); |
9 | | - }); |
10 | | - xit('repeats the string 1 times', function() { |
11 | | - expect(repeatString('hey', 1)).toEqual('hey'); |
12 | | - }); |
13 | | - xit('repeats the string 0 times', function() { |
14 | | - expect(repeatString('hey', 0)).toEqual(''); |
15 | | - }); |
16 | | - xit('returns ERROR with negative numbers', function() { |
17 | | - expect(repeatString('hey', -1)).toEqual('ERROR'); |
18 | | - }); |
19 | | - xit('repeats the string a random amount of times', function () { |
20 | | - /*The number is generated by using Math.random to get a value from between |
| 3 | +describe("repeatString", function () { |
| 4 | + it("repeats the string", function () { |
| 5 | + expect(repeatString("hey", 3)).toEqual("heyheyhey"); |
| 6 | + }); |
| 7 | + it("repeats the string many times", function () { |
| 8 | + expect(repeatString("hey", 10)).toEqual("heyheyheyheyheyheyheyheyheyhey"); |
| 9 | + }); |
| 10 | + it("repeats the string 1 times", function () { |
| 11 | + expect(repeatString("hey", 1)).toEqual("hey"); |
| 12 | + }); |
| 13 | + it("repeats the string 0 times", function () { |
| 14 | + expect(repeatString("hey", 0)).toEqual(""); |
| 15 | + }); |
| 16 | + it("returns ERROR with negative numbers", function () { |
| 17 | + expect(repeatString("hey", -1)).toEqual("ERROR"); |
| 18 | + }); |
| 19 | + it("repeats the string a random amount of times", function () { |
| 20 | + /*The number is generated by using Math.random to get a value from between |
21 | 21 | 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it |
22 | 22 | equals a number between 0 to 999 (this number will change everytime you run |
23 | 23 | the test).*/ |
24 | 24 |
|
25 | | - // DO NOT use Math.floor(Math.random() * 1000) in your code, |
26 | | - // this test generates a random number, then passes it into your code with a function parameter. |
27 | | - // If this doesn't make sense, you should go read about functions here: https://www.theodinproject.com/courses/web-development-101/lessons/fundamentals-part-3 |
28 | | - const number = Math.floor(Math.random() * 1000) |
29 | | - /*The .match(/((hey))/g).length is a regex that will count the number of heys |
| 25 | + // DO NOT use Math.floor(Math.random() * 1000) in your code, |
| 26 | + // this test generates a random number, then passes it into your code with a function parameter. |
| 27 | + // If this doesn't make sense, you should go read about functions here: https://www.theodinproject.com/courses/web-development-101/lessons/fundamentals-part-3 |
| 28 | + const number = Math.floor(Math.random() * 1000); |
| 29 | + /*The .match(/((hey))/g).length is a regex that will count the number of heys |
30 | 30 | in the result, which if your function works correctly will equal the number that |
31 | 31 | was randomaly generated. */ |
32 | | - expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number); |
33 | | - }); |
34 | | - xit('works with blank strings', function() { |
35 | | - expect(repeatString('', 10)).toEqual(''); |
36 | | - }); |
| 32 | + expect(repeatString("hey", number).match(/((hey))/g).length).toEqual(number); |
| 33 | + }); |
| 34 | + it("works with blank strings", function () { |
| 35 | + expect(repeatString("", 10)).toEqual(""); |
| 36 | + }); |
37 | 37 | }); |
0 commit comments