-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern_02.test.js
51 lines (48 loc) · 1.45 KB
/
Pattern_02.test.js
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
42
43
44
45
46
47
48
49
50
51
const rightTriangleStarPattern = require('../Pattern_02/Pattern_02');
describe('rightTriangleStarPattern', () => {
it('should print the right triangle star pattern for n=5', () => {
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
rightTriangleStarPattern(5);
expect(consoleSpy).toHaveBeenCalledTimes(5);
expect(consoleSpy.mock.calls).toEqual([
['* '],
['* * '],
['* * * '],
['* * * * '],
['* * * * * '],
]);
consoleSpy.mockRestore();
});
it('should print the right triangle star pattern for n=7', () => {
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
rightTriangleStarPattern(7);
expect(consoleSpy).toHaveBeenCalledTimes(7);
expect(consoleSpy.mock.calls).toEqual([
['* '],
['* * '],
['* * * '],
['* * * * '],
['* * * * * '],
['* * * * * * '],
['* * * * * * * '],
]);
consoleSpy.mockRestore();
});
it('should print the right triangle star pattern for n=9', () => {
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
rightTriangleStarPattern(9);
expect(consoleSpy).toHaveBeenCalledTimes(9);
expect(consoleSpy.mock.calls).toEqual([
['* '],
['* * '],
['* * * '],
['* * * * '],
['* * * * * '],
['* * * * * * '],
['* * * * * * * '],
['* * * * * * * * '],
['* * * * * * * * * '],
]);
consoleSpy.mockRestore();
});
});