Sha256: 6ad02be091c706594dfe4449ac853c3009de6bd0e28078db3d8fcfafe4b0ad47
Contents?: true
Size: 1.76 KB
Versions: 3
Compression:
Stored size: 1.76 KB
Contents
require 'spec_helper' describe GraphQL::Schema::TypeReducer do it 'finds types from a single type and its fields' do reducer = GraphQL::Schema::TypeReducer.new(CheeseType, {}) expected = { "Cheese" => CheeseType, "Int" => GraphQL::INT_TYPE, "String" => GraphQL::STRING_TYPE, "DairyAnimal" => DairyAnimalEnum, "Float" => GraphQL::FLOAT_TYPE, "Edible" => EdibleInterface, "Milk" => MilkType, "ID" => GraphQL::ID_TYPE, "AnimalProduct" => AnimalProductInterface, } assert_equal(expected.keys, reducer.result.keys) assert_equal(expected, reducer.result) end it 'finds type from arguments' do reducer = GraphQL::Schema::TypeReducer.new(QueryType, {}) assert_equal(DairyProductInputType, reducer.result["DairyProductInput"]) end describe 'when a type is invalid' do let(:invalid_type) { GraphQL::ObjectType.define do name "InvalidType" field :someField end } it 'raises an InvalidTypeError' do reducer = GraphQL::Schema::TypeReducer.new(invalid_type, {}) assert_raises(GraphQL::Schema::InvalidTypeError) { reducer.result } end end describe 'when a schema has multiple types with the same name' do let(:type_1) { GraphQL::ObjectType.define do name "MyType" end } let(:type_2) { GraphQL::ObjectType.define do name "MyType" end } it 'raises an error' do assert_raises(RuntimeError) { GraphQL::Schema::TypeReducer.find_all([type_1, type_2]) } end end describe 'when getting a type which doesnt exist' do it 'raises an error' do type_map = GraphQL::Schema::TypeReducer.find_all([]) assert_raises(RuntimeError) { type_map["SomeType"] } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.9.2 | spec/graphql/schema/type_reducer_spec.rb |
graphql-0.8.1 | spec/graphql/schema/type_reducer_spec.rb |
graphql-0.8.0 | spec/graphql/schema/type_reducer_spec.rb |