generated from dankinsoid/iOSLibraryTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75afb33
commit 5728a93
Showing
4 changed files
with
89 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import SwiftAPIClientMacros | ||
import SwiftSyntaxMacros | ||
import SwiftSyntaxMacrosTestSupport | ||
import XCTest | ||
|
||
final class APIMacroTests: XCTestCase { | ||
|
||
private let macros: [String: Macro.Type] = [ | ||
"API": SwiftAPIClientPathMacro.self | ||
] | ||
|
||
func testExpansionAPI() { | ||
assertMacroExpansion( | ||
""" | ||
@API | ||
struct Pets { | ||
} | ||
""", | ||
expandedSource: """ | ||
struct Pets { | ||
public typealias Body<Value> = _APIParameterWrapper<Value> | ||
public typealias Query<Value> = _APIParameterWrapper<Value> | ||
public var client: APIClient | ||
public init(client: APIClient) { | ||
self.client = client | ||
} | ||
} | ||
""", | ||
macros: macros, | ||
indentationWidth: .spaces(2) | ||
) | ||
} | ||
|
||
func testExpansionAPIWithInit() { | ||
assertMacroExpansion( | ||
""" | ||
@API | ||
struct Pets { | ||
init(client: APIClient) { | ||
self.client = client | ||
} | ||
} | ||
""", | ||
expandedSource: """ | ||
struct Pets { | ||
init(client: APIClient) { | ||
self.client = client | ||
} | ||
public typealias Body<Value> = _APIParameterWrapper<Value> | ||
public typealias Query<Value> = _APIParameterWrapper<Value> | ||
public var client: APIClient | ||
} | ||
""", | ||
macros: macros, | ||
indentationWidth: .spaces(2) | ||
) | ||
} | ||
} |
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