Skip to content

Commit

Permalink
fix Custom Scalar should not be edited. output (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsudamper committed Jan 22, 2024
1 parent 16c8e34 commit ebccdfa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -6,7 +6,8 @@ import ApolloAPI
import GraphQLCompiler

class CustomScalarTemplateTests: XCTestCase {
var subject: CustomScalarTemplate!
// Since the base protocol is actually used, Use TemplateRenderer. This can be confirmed that no unintended implementation is using.
var subject: TemplateRenderer!

// MARK: Helpers

Expand Down Expand Up @@ -57,7 +58,21 @@ class CustomScalarTemplateTests: XCTestCase {
// then
expect(rendered).to(equalLineByLine(expected))
}

// MARK: Header Tests

func test__contain_can_edited_header_description() throws {
// given
buildSubject()

// when
let rendered = subject.renderHeaderTemplate(nonFatalErrorRecorder: .init())

// then
expect(rendered?.description).toNot(contain("should not be edited"))
expect(rendered?.description).to(contain("can be edited"))
}

// MARK: Typealias Definition Tests

func test__render__givenCustomScalar_shouldGenerateStringTypealias() throws {
Expand Down
Expand Up @@ -14,7 +14,7 @@ struct CustomScalarTemplate: TemplateRenderer {

func renderHeaderTemplate(
nonFatalErrorRecorder: ApolloCodegen.NonFatalError.Recorder
) -> TemplateString {
) -> TemplateString? {
HeaderCommentTemplate.editableFileHeader(
fileCanBeEditedTo: "implement advanced custom scalar functionality."
)
Expand Down

0 comments on commit ebccdfa

Please sign in to comment.