Sha256: 29d8767aac6adb7e0ef3d0277fd98db58fc5a0eb848b50ced217877a6baa76d4

Contents?: true

Size: 884 Bytes

Versions: 6

Compression:

Stored size: 884 Bytes

Contents

require 'config'

class GraphQL_Type_Scalar_AnyScalarTest < GraphQL::TestCase
  DESCRIBED_CLASS = Rails::GraphQL::Type::Scalar::AnyScalar

  OBJECTS = {
    1 => [1, '1'],
    'a' => ['a', '"a"'],
    true => [true, 'true'],
    4.2 => [4.2, '4.2'],
    [1, 'a'] => [[1, 'a'], '[1,"a"]'],
    { a: 1, b: 'c' } => [{ 'a' => 1, 'b' => 'c' }, '{"a":1,"b":"c"}'],
  }

  def test_valid_input_ask
    OBJECTS.each_value do |(val, _)|
      assert(DESCRIBED_CLASS.valid_input?(val))
    end
  end

  def test_valid_output_ask
    OBJECTS.each_value do |(val, _)|
      assert(DESCRIBED_CLASS.valid_output?(val))
    end
  end

  def test_to_json
    OBJECTS.each do |source, (_, val)|
      assert_equal(val, DESCRIBED_CLASS.to_json(source))
    end
  end

  def test_as_json
    OBJECTS.each do |source, (val, _)|
      assert_equal(val, DESCRIBED_CLASS.as_json(source))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-graphql-1.0.2 test/graphql/type/scalar/any_scalar_test.rb
rails-graphql-1.0.1 test/graphql/type/scalar/any_scalar_test.rb
rails-graphql-1.0.0 test/graphql/type/scalar/any_scalar_test.rb
rails-graphql-1.0.0.rc2 test/graphql/type/scalar/any_scalar_test.rb
rails-graphql-1.0.0.rc1 test/graphql/type/scalar/any_scalar_test.rb
rails-graphql-1.0.0.beta test/graphql/type/scalar/any_scalar_test.rb