Skip to content

Commit

Permalink
Namespace ApolloAPI in InterfaceTemplate (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMDev authored and gh-action-runner committed May 14, 2024
1 parent fe518ec commit a668ecf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InterfaceTemplateTests: XCTestCase {
buildSubject(name: "aDog")

let expected = """
static let ADog = Interface(name: "aDog")
static let ADog = ApolloAPI.Interface(name: "aDog")
"""

// when
Expand All @@ -64,7 +64,7 @@ class InterfaceTemplateTests: XCTestCase {

let expected = """
/// \(documentation)
static let Dog = Interface(name: "Dog")
static let Dog = ApolloAPI.Interface(name: "Dog")
"""

// when
Expand All @@ -84,7 +84,7 @@ class InterfaceTemplateTests: XCTestCase {
)

let expected = """
static let Dog = Interface(name: "Dog")
static let Dog = ApolloAPI.Interface(name: "Dog")
"""

// when
Expand All @@ -94,6 +94,26 @@ class InterfaceTemplateTests: XCTestCase {
expect(rendered).to(equalLineByLine(expected, ignoringExtraLines: true))
}

// MARK: Namespacing Tests

func test_render_givenCocoapodsCompatibleImportStatements_generatesWithApolloNamespace() throws {
// given
buildSubject(
name: "Dog",
config: .mock(.other, options: .init(cocoapodsCompatibleImportStatements: true))
)

let expected = """
static let Dog = Apollo.Interface(name: "Dog")
"""

// when
let actual = renderSubject()

// then
expect(actual).to(equalLineByLine(expected))
}

// MARK: - Reserved Keyword Tests

func test_render_givenSchemaInterfaceUsingReservedKeyword_generatesWithEscapedType() throws {
Expand All @@ -104,7 +124,7 @@ class InterfaceTemplateTests: XCTestCase {
buildSubject(name: keyword)

let expected = """
static let \(keyword.firstUppercased)_Interface = Interface(name: "\(keyword)")
static let \(keyword.firstUppercased)_Interface = ApolloAPI.Interface(name: "\(keyword)")
"""

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct InterfaceTemplate: TemplateRenderer {
) -> TemplateString {
"""
\(documentation: graphqlInterface.documentation, config: config)
static let \(graphqlInterface.formattedName) = Interface(name: "\(graphqlInterface.name)")
static let \(graphqlInterface.formattedName) = \(config.ApolloAPITargetName).Interface(name: "\(graphqlInterface.name)")
"""
}
}

0 comments on commit a668ecf

Please sign in to comment.