Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace ApolloAPI in InterfaceTemplate #359

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)")
"""
}
}
Loading