forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLineHelp.test.ts
More file actions
42 lines (33 loc) · 1.23 KB
/
CommandLineHelp.test.ts
File metadata and controls
42 lines (33 loc) · 1.23 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
42
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as colors from 'colors';
import * as path from 'path';
import { RushCommandLineParser } from '../RushCommandLineParser';
describe('CommandLineHelp', () => {
let oldCwd: string | undefined;
let parser: RushCommandLineParser;
beforeEach(() => {
oldCwd = process.cwd();
const localCwd: string = path.join(__dirname, 'repo');
process.chdir(localCwd);
// This call may terminate the entire test run because it invokes process.exit()
// if it encounters errors.
// TODO Remove the calls to process.exit() or override them for testing.
parser = new RushCommandLineParser();
});
it('prints the global help', () => {
const helpText: string = colors.stripColors(parser.renderHelpText());
expect(helpText).toMatchSnapshot();
});
it(`prints the help for each action`, () => {
for (const action of parser.actions) {
const helpText: string = colors.stripColors(action.renderHelpText());
expect(helpText).toMatchSnapshot(action.actionName);
}
});
afterEach(() => {
if (oldCwd) {
process.chdir(oldCwd);
}
});
});