/
help-spec.ts
86 lines (73 loc) · 3.67 KB
/
help-spec.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { spawnSync } from "child_process";
describe("Help command", () => {
it("should list all available commands", async done => {
const child = spawnSync("node", ["bin/execute.js", "--help" ], {
encoding: "utf-8"
});
const originalHelpText: string = `Commands:
quickstart A quick start for your project
start start the project
new [name] Creating a new project
generate Generates new project [aliases: g]
build build the project
config Get or set configuration properties
test test the project
add [template] [name] Add component by it ID and providing a name.
Options:
--version, -v Show current Ignite UI CLI version [boolean]
--help, -h Show help [boolean]`;
const replacedHelpText: string = originalHelpText.replace(/\s/g, "");
const actualText: string = (child.stdout.toString("utf-8")).replace(/\s/g, "");
expect(replacedHelpText).toEqual(actualText);
done();
});
it("should show help for individual commands", async done => {
const child = spawnSync("node", ["bin/execute.js", "new", "--help" ], {
encoding: "utf-8"
});
const originalNewHelpText: string = `Options:
--version, -v Show current Ignite UI CLI version [boolean]
--help, -h Show help [boolean]
--name, -n Project name [string]
--framework, -f Framework to setup project for
[string] [choices: "angular", "jquery", "react"] [default: "jquery"]
--type, -t Project type (depends on framework) [string]
--theme, --th Project theme (depends on project type) [string]`;
const replacedNewHelpText: string = originalNewHelpText.replace(/\s/g, "");
const actualNewText: string = (child.stdout.toString("utf-8")).replace(/\s/g, "");
expect(actualNewText).toContain(replacedNewHelpText);
done();
});
it("should show help config sub-commands", async done => {
const child = spawnSync("node", ["bin/execute.js", "config", "--help" ], {
encoding: "utf-8"
});
const originalNewHelpText: string = `Commands:
get <property> Get configuration properties
set <property> <value> Set configuration properties
add <property> <value> Add a value to an existing configuration array
Options:
--version, -v Show current Ignite UI CLI version [boolean]
--help, -h Show help [boolean]
--global, -g Specify if the global configuration should be used [boolean]`;
const replacedNewHelpText: string = originalNewHelpText.replace(/\s/g, "");
const actualNewText: string = (child.stdout.toString("utf-8")).replace(/\s/g, "");
expect(actualNewText).toContain(replacedNewHelpText);
done();
});
it("should show help generate sub-commands", async done => {
const child = spawnSync("node", ["bin/execute.js", "generate", "--help" ], {
encoding: "utf-8"
});
const originalNewHelpText: string = `Commands:
template [name] [framework] [type] Generates custom template
[skip-config] [aliases: t]
Options:
--version, -v Show current Ignite UI CLI version [boolean]
--help, -h Show help [boolean]`;
const replacedNewHelpText: string = originalNewHelpText.replace(/\s/g, "");
const actualNewText: string = (child.stdout.toString("utf-8")).replace(/\s/g, "");
expect(actualNewText).toContain(replacedNewHelpText);
done();
});
});