Skip to content

Commit

Permalink
Improve the completion tests a bit (apple#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
natecook1000 authored Aug 12, 2020
1 parent 6180c8b commit b905f5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
25 changes: 25 additions & 0 deletions Tests/ArgumentParserExampleTests/MathExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,31 @@ extension MathExampleTests {
command: "math --generate-completion-script zsh",
expected: zshCompletionScriptText)
}

func testMath_CustomCompletion() {
AssertExecuteCommand(
command: "math ---completion stats quantiles -- --custom",
expected: """
hello
helicopter
heliotrope
""")

AssertExecuteCommand(
command: "math ---completion stats quantiles -- --custom h",
expected: """
hello
helicopter
heliotrope
""")

AssertExecuteCommand(
command: "math ---completion stats quantiles -- --custom a",
expected: """
aardvark
aaaaalbert
""")
}
}

private let bashCompletionScriptText = """
Expand Down
11 changes: 1 addition & 10 deletions Tests/ArgumentParserUnitTests/CompletionScriptTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,7 @@ extension CompletionScriptTests {
}

func testEscaped_Zsh() throws {
let script1 = try CompletionsGenerator(command: Escaped.self, shell: .zsh)
.generateCompletionScript()
XCTAssertEqual(zshEscapedCompletion, script1)

let script2 = try CompletionsGenerator(command: Escaped.self, shellName: "zsh")
.generateCompletionScript()
XCTAssertEqual(zshEscapedCompletion, script2)

let script3 = Escaped.completionScript(for: .zsh)
XCTAssertEqual(zshEscapedCompletion, script3)
XCTAssertEqual(zshEscapedCompletion, Escaped.completionScript(for: .zsh))
}
}

Expand Down

0 comments on commit b905f5c

Please sign in to comment.