File tree 1 file changed +11
-0
lines changed 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,15 @@ describe('repeatString', function() {
16
16
xit ( 'returns ERROR with negative numbers' , function ( ) {
17
17
expect ( repeatString ( 'hey' , - 1 ) ) . toEqual ( 'ERROR' ) ;
18
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
21
+ 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
22
+ equals a number between 0 to 999 (this number will change everytime you run
23
+ the test).*/
24
+ const number = Math . floor ( Math . random ( ) * 1000 )
25
+ /*The .match(/((hey))/g).length is a regex that will count the number of heys
26
+ in the result, which if your function works correctly will equal the number that
27
+ was randomaly generated. */
28
+ expect ( repeatString ( 'hey' , number ) . match ( / ( ( h e y ) ) / g) . length ) . toEqual ( number ) ;
29
+ } ) ;
19
30
} ) ;
You can’t perform that action at this time.
0 commit comments