Skip to content

Commit f254d55

Browse files
committed
Added CLI Test cases
1 parent e348da6 commit f254d55

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/unit/cli.spec.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,45 @@ export class CLITests {
1111
@TestCase("dontRequireLuaLib", false)
1212
@TestCase("rootDir", process.cwd())
1313
@TestCase("outDir", process.cwd())
14-
public defaultOptions(option: string, expected: string) {
14+
public defaultOptions(option: any, expected: any) {
1515
let parsedCommandLine = parseCommandLine([]);
1616

17-
Expect(parsedCommandLine.options[option]).toBe(expected);
17+
Expect(expected).toBe(parsedCommandLine.options[option]);
1818
}
1919

2020
@Test("InvalidLuaTarget")
2121
public invalidLuaTarget() {
2222
// Don't check error message because the yargs library messes the message up.
2323
Expect(() => parseCommandLine(['--luaTarget', '42'])).toThrow();
2424
}
25+
26+
@Test("InvalidArgument")
27+
public invalidArgument() {
28+
// Don't check error message because the yargs library messes the message up.
29+
Expect(() => parseCommandLine(['--invalidTarget', 'test'])).toThrow();
30+
}
31+
32+
@Test("outDir")
33+
public outDir() {
34+
let parsedCommandLine = parseCommandLine(['--outDir', './test']);
35+
36+
Expect(parsedCommandLine.options['outDir']).toBe('./test');
37+
}
38+
39+
@Test("rootDir")
40+
public rootDir() {
41+
let parsedCommandLine = parseCommandLine(['--rootDir', './test']);
42+
43+
Expect(parsedCommandLine.options['rootDir']).toBe('./test');
44+
Expect(parsedCommandLine.options['outDir']).toBe('./test');
45+
}
46+
47+
@Test("outDirAndRooDir")
48+
public outDirAndRooDir() {
49+
let parsedCommandLine = parseCommandLine(['--outDir', './testOut', '--rootDir', './testRoot']);
50+
51+
Expect(parsedCommandLine.options['outDir']).toBe('./testOut');
52+
Expect(parsedCommandLine.options['rootDir']).toBe('./testRoot');
53+
}
54+
2555
}

0 commit comments

Comments
 (0)