forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-step3.test.js
More file actions
41 lines (32 loc) · 1.12 KB
/
3-step3.test.js
File metadata and controls
41 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { HOMEWORK_FOLDER } = require('../../test-config');
const {
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile
} = require(`../${HOMEWORK_FOLDER}/3-step3`);
describe('1-step3.js', () => {
test('for-loop', () => {
let result = repeatStringNumTimesWithFor('abc', 3);
expect(result).toBe('abcabcabc');
result = repeatStringNumTimesWithFor('abc', 1);
expect(result).toBe('abc');
result = repeatStringNumTimesWithFor('abc', -2);
expect(result).toBe('');
});
test('while-loop', () => {
let result = repeatStringNumTimesWithWhile('abc', 3);
expect(result).toBe('abcabcabc');
result = repeatStringNumTimesWithFor('abc', 1);
expect(result).toBe('abc');
result = repeatStringNumTimesWithFor('abc', -2);
expect(result).toBe('');
});
test('do-while-loop', () => {
let result = repeatStringNumTimesWithDoWhile('abc', 3);
expect(result).toBe('abcabcabc');
result = repeatStringNumTimesWithFor('abc', 1);
expect(result).toBe('abc');
result = repeatStringNumTimesWithFor('abc', -2);
expect(result).toBe('');
});
});