Skip to content

Commit

Permalink
Add test for reproduction of #2928
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMDev committed Apr 6, 2023
1 parent f711478 commit 40df726
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Tests/ApolloTests/TestMockTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,27 @@ class TestMockTests: XCTestCase {
// then
expect(selectionSet.__data._data["species"]).to(beNil())
}

func test__convertToSelectionSet__givenGraphQLEnumField__canAccessField() throws {
// given
class Animal: TestMockSchema.MockSelectionSet {
override class var __parentType: ParentType { TestMockSchema.Interfaces.Animal }
override class var __selections: [Selection] {[
.field("speciesType", GraphQLEnum<Species>.self),
]}

var speciesType: GraphQLEnum<Species> { __data["speciesType"] }
}

let mock = Mock<Dog>()
mock.speciesType = GraphQLEnum(Species.canine)

// when
let selectionSet = Animal.from(mock)

// then
expect(selectionSet.speciesType).to(equal(.case(.canine)))
}
}

// MARK: - Generated Example
Expand Down Expand Up @@ -537,6 +558,16 @@ class Dog: MockObject {
}
}

extension Mock where O == Dog {
convenience init(
speciesType: GraphQLEnum<Species>? = nil
) {
self.init()
self.speciesType = speciesType
}
}


class Cat: MockObject {
static let objectType: Object = TestMockSchema.Types.Cat
static let _mockFields = MockFields()
Expand Down

0 comments on commit 40df726

Please sign in to comment.