|
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('hello', 10)).toEqual('hellohellohellohellohellohellohellohellohellohello'); |
| 7 | + test("repeats the string many times", () => { |
| 8 | + expect(repeatString("hello", 10)).toEqual( |
| 9 | + "hellohellohellohellohellohellohellohellohellohello" |
| 10 | + ); |
9 | 11 | });
|
10 |
| - test.skip('repeats the string 1 times', () => { |
11 |
| - expect(repeatString('hi', 1)).toEqual('hi'); |
| 12 | + test("repeats the string 1 times", () => { |
| 13 | + expect(repeatString("hi", 1)).toEqual("h
10000
i"); |
12 | 14 | });
|
13 |
| - test.skip('repeats the string 0 times', () => { |
14 |
| - expect(repeatString('bye', 0)).toEqual(''); |
| 15 | + test("repeats the string 0 times", () => { |
| 16 | + expect(repeatString("bye", 0)).toEqual(""); |
15 | 17 | });
|
16 |
| - test.skip('returns ERROR with negative numbers', () => { |
17 |
| - expect(repeatString('goodbye', -1)).toEqual('ERROR'); |
| 18 | + test("returns ERROR with negative numbers", () => { |
| 19 | + expect(repeatString("goodbye", -1)).toEqual("ERROR"); |
18 | 20 | });
|
19 |
| - test.skip('repeats the string a random amount of times', function () { |
| 21 | + test("repeats the string a random amount of times", function () { |
20 | 22 | /*The number is generated by using Math.random to get a value from between
|
21 | 23 | 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
|
22 | 24 | equals a number between 0 to 999 (this number will change everytime you run
|
23 | 25 | the test).*/
|
24 | 26 |
|
25 |
| - // DO NOT use Math.floor(Math.random() * 1000) in your code, |
| 27 | + // DO NOT use Math.floor(Math.random() * 1000) in your code, |
26 | 28 | // this test generates a random number, then passes it into your code with a function parameter.
|
27 | 29 | // 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) |
| 30 | + const number = Math.floor(Math.random() * 1000); |
29 | 31 | /*The .match(/((hey))/g).length is a regex that will count the number of heys
|
30 | 32 | in the result, which if your function works correctly will equal the number that
|
31 | 33 | was randomly generated. */
|
32 |
| - expect(repeatString('odin', number).match(/((odin))/g).length).toEqual(number); |
| 34 | + expect(repeatString("odin", number).match(/((odin))/g).length).toEqual( |
| 35 | + number |
| 36 | + ); |
33 | 37 | });
|
34 |
| - test.skip('works with blank strings', () => { |
35 |
| - expect(repeatString('', 10)).toEqual(''); |
| 38 | + test("works with blank strings", () => { |
| 39 | + expect(repeatString("", 10)).toEqual(""); |
36 | 40 | });
|
37 | 41 | });
|
0 commit comments