Sha256: fefddeb8d90676c8a31af4b510a2da56352d4afa5ade5e5ce715806a8fc16e3d

Contents?: true

Size: 837 Bytes

Versions: 16

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'

describe GraphQL::UnionType do
  let(:type_1) { OpenStruct.new(kind: GraphQL::TypeKinds::OBJECT)}
  let(:type_2) { OpenStruct.new(kind: GraphQL::TypeKinds::OBJECT)}
  let(:type_3) { OpenStruct.new(kind: GraphQL::TypeKinds::SCALAR)}
  let(:union) {
    types = [type_1, type_2]
    GraphQL::UnionType.define {
      name("MyUnion")
      description("Some items")
      possible_types(types)
    }
  }
  it 'has a name' do
    assert_equal("MyUnion", union.name)
  end

  it 'infers type from an object' do
    assert_equal(CheeseType, DairyProductUnion.resolve_type(CHEESES[1]))
  end

  it '#include? returns true if type in in possible_types' do
    assert union.include?(type_1)
  end

  it '#include? returns false if type is not in possible_types' do
    assert_equal(false, union.include?(type_3))
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql-0.12.1 spec/graphql/union_type_spec.rb
graphql-0.12.0 spec/graphql/union_type_spec.rb
graphql-0.11.1 spec/graphql/union_type_spec.rb
graphql-0.11.0 spec/graphql/union_type_spec.rb
graphql-0.10.9 spec/graphql/union_type_spec.rb
graphql-0.10.8 spec/graphql/union_type_spec.rb
graphql-0.10.7 spec/graphql/union_type_spec.rb
graphql-0.10.6 spec/graphql/union_type_spec.rb
graphql-0.10.5 spec/graphql/union_type_spec.rb
graphql-0.10.4 spec/graphql/union_type_spec.rb
graphql-0.10.3 spec/graphql/union_type_spec.rb
graphql-0.10.2 spec/graphql/union_type_spec.rb
graphql-0.10.1 spec/graphql/union_type_spec.rb
graphql-0.10.0 spec/graphql/union_type_spec.rb
graphql-0.9.5 spec/graphql/union_type_spec.rb
graphql-0.9.4 spec/graphql/union_type_spec.rb