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