|
1 | | -const repeatString = require('./repeatString') |
| 1 | +const repeatString = require("./repeatString"); |
2 | 2 |
|
3 | | -describe('repeatString', () => { |
4 | | - test('repeats the string', () => { |
5 | | - expect(repeatString('hey', 3)).toEqual('heyheyhey'); |
| 3 | +describe("repeatString", () => { |
| 4 | + test("repeats the string", () => { |
| 5 | + expect(repeatString("hey", 3)).toEqual("heyheyhey"); |
6 | 6 | }); |
7 | | - test.skip('repeats the string many times', () => { |
8 | | - expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey'); |
| 7 | + test("repeats the string many times", () => { |
| 8 | + expect(repeatString("hey", 10)).toEqual("heyheyheyheyheyheyheyheyheyhey"); |
9 | 9 | }); |
10 | | - test.skip('repeats the string 1 times', () => { |
11 | | - expect(repeatString('hey', 1)).toEqual('hey'); |
| 10 | + test("repeats the string 1 times", () => { |
| 11 | + expect(repeatString("hey", 1)).toEqual("hey"); |
12 | 12 | }); |
13 | | - test.skip('repeats the string 0 times', () => { |
14 | | - expect(repeatString('hey', 0)).toEqual(''); |
| 13 | + test("repeats the string 0 times", () => { |
| 14 | + expect(repeatString("hey", 0)).toEqual(""); |
15 | 15 | }); |
16 | | - test.skip('returns ERROR with negative numbers', () => { |
17 | | - expect(repeatString('hey', -1)).toEqual('ERROR'); |
| 16 | + test("returns ERROR with negative numbers", () => { |
| 17 | + expect(repeatString("hey", -1)).toEqual("ERROR"); |
18 | 18 | }); |
19 | | - test.skip('repeats the string a random amount of times', function () { |
| 19 | + test("repeats the string a random amount of times", function () { |
20 | 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, |
| 25 | + // DO NOT use Math.floor(Math.random() * 1000) in your code, |
26 | 26 | // this test generates a random number, then passes it into your code with a function parameter. |
27 | 27 | // If this doesn't make sense, you should go read about functions here: https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/fundamentals-part-3 |
28 | | - const number = Math.floor(Math.random() * 1000) |
| 28 | + const number = Math.floor(Math.random() * 1000); |
29 | 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 randomly generated. */ |
32 | | - expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number); |
| 32 | + expect(repeatString("hey", number).match(/((hey))/g).length).toEqual( |
| 33 | + number |
| 34 | + ); |
33 | 35 | }); |
34 | | - test.skip('works with blank strings', () => { |
35 | | - expect(repeatString('', 10)).toEqual(''); |
| 36 | + test("works with blank strings", () => { |
| 37 | + expect(repeatString("", 10)).toEqual(""); |
36 | 38 | }); |
37 | 39 | }); |
0 commit comments