-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from snyk-labs/fix/snyk_description_on_helm_ou…
…tput Fix/snyk description on helm output
- Loading branch information
Showing
6 changed files
with
443 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
node_modules | ||
dist | ||
.eslintcache | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,69 @@ | ||
import { IArgs, parseInputParameters } from "../cli-args"; | ||
|
||
test("handles dot or actual path as input", () => { | ||
let inputArgs = ["."]; | ||
let parsedArgs: IArgs = parseInputParameters(inputArgs); | ||
expect(parsedArgs.inputDirectory).toBe("."); | ||
expect(parsedArgs.debug).toBe(false); | ||
describe("test command", () => { | ||
describe("check required input directory", () => { | ||
test("process exit if there is no <chart-directory> required arg", () => { | ||
const inputArgs = ["test"]; | ||
//@ts-ignore | ||
const mockProcessExit = jest.spyOn(process, "exit").mockImplementation(code => {}); | ||
|
||
parseInputParameters(inputArgs); | ||
expect(mockProcessExit).toHaveBeenCalledWith(1); | ||
mockProcessExit.mockRestore(); | ||
}); | ||
|
||
test("handles dot as input", () => { | ||
const inputArgs = ["test", "."]; | ||
|
||
const parsedArgs = parseInputParameters(inputArgs); | ||
|
||
expect(parsedArgs.inputDirectory).toBe("."); | ||
expect(parsedArgs.debug).toBe(false); | ||
}); | ||
|
||
test("handle absolute path as input", () => { | ||
const inputArgs = ["test", "/some/other/path"]; | ||
const parsedArgs = parseInputParameters(inputArgs); | ||
|
||
expect(parsedArgs.inputDirectory).toBe("/some/other/path"); | ||
|
||
expect(parsedArgs.debug).toBe(false); | ||
}); | ||
|
||
inputArgs = ["/some/other/path"]; | ||
parsedArgs = parseInputParameters(inputArgs); | ||
expect(parsedArgs.inputDirectory).toBe("/some/other/path"); | ||
expect(parsedArgs.debug).toBe(false); | ||
test("handle relative path as input", () => { | ||
const inputArgs = ["test", "~/other/path"]; | ||
|
||
inputArgs = ["~/other/path"]; | ||
parsedArgs = parseInputParameters(inputArgs); | ||
expect(parsedArgs.inputDirectory).toBe("~/other/path"); | ||
expect(parsedArgs.debug).toBe(false); | ||
const parsedArgs = parseInputParameters(inputArgs); | ||
|
||
expect(parsedArgs.inputDirectory).toBe("~/other/path"); | ||
expect(parsedArgs.debug).toBe(false); | ||
}); | ||
}); | ||
}); | ||
|
||
test("yargs causes process exit if no args", () => { | ||
//@ts-ignore | ||
const mockProcessExit = jest.spyOn(process, "exit").mockImplementation(code => {}); | ||
const inputArgs = []; | ||
const parsedArgs = parseInputParameters(inputArgs); | ||
|
||
parseInputParameters(inputArgs); | ||
expect(mockProcessExit).toHaveBeenCalledWith(1); | ||
mockProcessExit.mockRestore(); | ||
}); | ||
|
||
test("handles debug flag", () => { | ||
let inputArgs = [".", "--debug"]; | ||
let parsedArgs: IArgs = parseInputParameters(inputArgs); | ||
const inputArgs = ["test", ".", "--debug"]; | ||
const parsedArgs: IArgs = parseInputParameters(inputArgs); | ||
expect(parsedArgs.inputDirectory).toBe("."); | ||
expect(parsedArgs.debug).toBe(true); | ||
}); | ||
|
||
inputArgs = [ | ||
".", | ||
"-d" // make sure it works with the short form '-d', too | ||
]; | ||
parsedArgs = parseInputParameters(inputArgs); | ||
expect(parsedArgs.inputDirectory).toBe("."); | ||
expect(parsedArgs.debug).toBe(true); | ||
describe("Handle json flag", () => { | ||
test("option --json", () => { | ||
const inputArgs = ["test", ".", "--json"]; | ||
|
||
const parsedArgs: IArgs = parseInputParameters(inputArgs); | ||
|
||
expect(parsedArgs.json).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.