-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathprintWelcome.test.ts
More file actions
30 lines (26 loc) · 905 Bytes
/
printWelcome.test.ts
File metadata and controls
30 lines (26 loc) · 905 Bytes
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
import { test, vi, describe, expect, beforeEach } from 'vitest';
import chalk from 'chalk';
import printWelcome from '../printWelcome';
const consoleSpy = vi.spyOn(console, 'log');
describe('printWelcome', () => {
beforeEach(() => {
consoleSpy.mockClear();
});
test('prints introduction message', () => {
process.argv = ['node', 'script.js', 'create'];
printWelcome();
expect(console.log).toHaveBeenCalledWith(chalk.bold('\n\n\t👖 Belt 👖\n'));
});
describe('does not print introduction message for version', () => {
test('works for --version', () => {
process.argv = ['node', 'script.js', '--version'];
printWelcome();
expect(consoleSpy.mock.calls.length).toBe(0);
});
test('works for -V', () => {
process.argv = ['node', 'script.js', '-V'];
printWelcome();
expect(consoleSpy.mock.calls.length).toBe(0);
});
});
});