Sha256: a8d82344be1f4dcb86c61327b02a72fb003d6b31c458592f5dca01b17b595036

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

require 'config'

class GraphQL_TypeTest < GraphQL::TestCase
  class DESCRIBED_CLASS < Rails::GraphQL::Type; end

  def test_inherited
    assert_equal(DESCRIBED_CLASS, DESCRIBED_CLASS.base_type)
    assert_predicate(DESCRIBED_CLASS, :described_class?)
    assert_predicate(DESCRIBED_CLASS, :spec_object?)
    assert_predicate(DESCRIBED_CLASS, :base_object?)
    assert_predicate(DESCRIBED_CLASS, :abstract?)

    other_class = unmapped_class(DESCRIBED_CLASS)
    assert_equal(DESCRIBED_CLASS, other_class.base_type)
    assert_predicate(other_class, :described_class?)
    refute_predicate(other_class, :spec_object?)
    refute_predicate(other_class, :base_object?)
    refute_predicate(other_class, :abstract?)
  end

  def test_equivalence
    assert_operator(Rails::GraphQL::Type, :=~, DESCRIBED_CLASS)
    assert_operator(Rails::GraphQL::Type, :=~, DESCRIBED_CLASS.new)
    assert_operator(DESCRIBED_CLASS, :=~, DESCRIBED_CLASS.new)

    refute_operator(Rails::GraphQL::Type::Scalar, :=~, DESCRIBED_CLASS)
  end

  def test_kind
    assert_equal(:described_class, DESCRIBED_CLASS.kind)
  end

  def test_kind_enum
    assert_equal('DESCRIBED_CLASS', DESCRIBED_CLASS.kind_enum)
  end

  def test_decorate
    assert_equal(1, DESCRIBED_CLASS.decorate(1))
  end

  def test_kind_ask
    assert_respond_to(DESCRIBED_CLASS, :scalar?)
    assert_respond_to(DESCRIBED_CLASS, :object?)
    assert_respond_to(DESCRIBED_CLASS, :interface?)
    assert_respond_to(DESCRIBED_CLASS, :union?)
    assert_respond_to(DESCRIBED_CLASS, :enum?)
    assert_respond_to(DESCRIBED_CLASS, :input?)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-graphql-1.0.2 test/graphql/type_test.rb
rails-graphql-1.0.1 test/graphql/type_test.rb
rails-graphql-1.0.0 test/graphql/type_test.rb
rails-graphql-1.0.0.rc2 test/graphql/type_test.rb
rails-graphql-1.0.0.rc1 test/graphql/type_test.rb
rails-graphql-1.0.0.beta test/graphql/type_test.rb