mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
added alternate repeatString test strings
This commit is contained in:
@@ -5,16 +5,16 @@ describe('repeatString', () => {
|
||||
expect(repeatString('hey', 3)).toEqual('heyheyhey');
|
||||
});
|
||||
test('repeats the string many times', () => {
|
||||
expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey');
|
||||
expect(repeatString('hello', 10)).toEqual('hellohellohellohellohellohellohellohellohellohello');
|
||||
});
|
||||
test('repeats the string 1 times', () => {
|
||||
expect(repeatString('hey', 1)).toEqual('hey');
|
||||
expect(repeatString('hi', 1)).toEqual('hi');
|
||||
});
|
||||
test('repeats the string 0 times', () => {
|
||||
expect(repeatString('hey', 0)).toEqual('');
|
||||
expect(repeatString('bye', 0)).toEqual('');
|
||||
});
|
||||
test('returns ERROR with negative numbers', () => {
|
||||
expect(repeatString('hey', -1)).toEqual('ERROR');
|
||||
expect(repeatString('goodbye', -1)).toEqual('ERROR');
|
||||
});
|
||||
test('repeats the string a random amount of times', function () {
|
||||
/*The number is generated by using Math.random to get a value from between
|
||||
@@ -29,7 +29,7 @@ describe('repeatString', () => {
|
||||
/*The .match(/((hey))/g).length is a regex that will count the number of heys
|
||||
in the result, which if your function works correctly will equal the number that
|
||||
was randomaly generated. */
|
||||
expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(
|
||||
expect(repeatString('odin', number).match(/((odin))/g).length).toEqual(
|
||||
number
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user