Sha256: 3a82d9dc0afbab90c31f45ea196d9293146a39816b3dfb67709431d661b05541

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

require 'spec_helper'

describe GraphQL::ObjectType do
  let(:type) { CheeseType }

  it 'has a name' do
    assert_equal("Cheese", type.name)
    type.name = "Fromage"
    assert_equal("Fromage", type.name)
    type.name = "Cheese"
  end

  it 'has a description' do
    assert_equal(22, type.description.length)
  end

  it 'may have interfaces' do
    assert_equal([EdibleInterface, AnimalProductInterface], type.interfaces)
  end

  describe '.fields ' do
    it 'exposes fields' do
      field = type.fields["id"]
      assert_equal(GraphQL::TypeKinds::NON_NULL, field.type.kind)
      assert_equal(GraphQL::TypeKinds::SCALAR, field.type.of_type.kind)
    end

    it 'exposes defined field property' do
      field_without_prop = CheeseType.fields['flavor']
      field_with_prop = CheeseType.fields['fatContent']
      assert_equal(field_without_prop.property, nil)
      assert_equal(field_with_prop.property, :fat_content)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-0.11.0 spec/graphql/object_type_spec.rb