Skip to content

Commit

Permalink
Add test case to SpyFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshiki-tsukada committed Jun 21, 2024
1 parent fee164e commit c22f00b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Tests/SpyableMacroTests/Factories/UT_SpyFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ final class UT_SpyFactory: XCTestCase {
)
}

func testDeclarationExistentialTypeArguments() throws {
try assertProtocol(
withDeclaration: """
protocol ViewModelProtocol {
func foo(model: any ModelProtocol)
}
""",
expectingClassDeclaration: """
class ViewModelProtocolSpy: ViewModelProtocol {
var fooModelCallsCount = 0
var fooModelCalled: Bool {
return fooModelCallsCount > 0
}
var fooModelReceivedModel: (any ModelProtocol)?
var fooModelReceivedInvocations: [any ModelProtocol] = []
var fooModelClosure: ((any ModelProtocol) -> Void)?
func foo(model: any ModelProtocol) {
fooModelCallsCount += 1
fooModelReceivedModel = (model)
fooModelReceivedInvocations.append((model))
fooModelClosure?(model)
}
}
"""
)
}

func testDeclarationEscapingAutoClosureArgument() throws {
try assertProtocol(
withDeclaration: """
Expand Down

0 comments on commit c22f00b

Please sign in to comment.