Skip to content

Commit b905f5c

Browse files
authored
Improve the completion tests a bit (#228)
1 parent 6180c8b commit b905f5c

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

Tests/ArgumentParserExampleTests/MathExampleTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,31 @@ extension MathExampleTests {
185185
command: "math --generate-completion-script zsh",
186186
expected: zshCompletionScriptText)
187187
}
188+
189+
func testMath_CustomCompletion() {
190+
AssertExecuteCommand(
191+
command: "math ---completion stats quantiles -- --custom",
192+
expected: """
193+
hello
194+
helicopter
195+
heliotrope
196+
""")
197+
198+
AssertExecuteCommand(
199+
command: "math ---completion stats quantiles -- --custom h",
200+
expected: """
201+
hello
202+
helicopter
203+
heliotrope
204+
""")
205+
206+
AssertExecuteCommand(
207+
command: "math ---completion stats quantiles -- --custom a",
208+
expected: """
209+
aardvark
210+
aaaaalbert
211+
""")
212+
}
188213
}
189214

190215
private let bashCompletionScriptText = """

Tests/ArgumentParserUnitTests/CompletionScriptTests.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,7 @@ extension CompletionScriptTests {
116116
}
117117

118118
func testEscaped_Zsh() throws {
119-
let script1 = try CompletionsGenerator(command: Escaped.self, shell: .zsh)
120-
.generateCompletionScript()
121-
XCTAssertEqual(zshEscapedCompletion, script1)
122-
123-
let script2 = try CompletionsGenerator(command: Escaped.self, shellName: "zsh")
124-
.generateCompletionScript()
125-
XCTAssertEqual(zshEscapedCompletion, script2)
126-
127-
let script3 = Escaped.completionScript(for: .zsh)
128-
XCTAssertEqual(zshEscapedCompletion, script3)
119+
XCTAssertEqual(zshEscapedCompletion, Escaped.completionScript(for: .zsh))
129120
}
130121
}
131122

0 commit comments

Comments
 (0)