Sha256: 3177facee5cfc2173dc91ae7cc62442c25fa6e1cd64a6082bae912ac3657d02a

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require 'config'

class GraphQL_Type_Scalar_BooleanScalarTest < GraphQL::TestCase
  DESCRIBED_CLASS = Rails::GraphQL::Type::Scalar::BooleanScalar

  def test_valid_input_ask
    assert(DESCRIBED_CLASS.valid_input?(true))
    assert(DESCRIBED_CLASS.valid_input?(false))

    refute(DESCRIBED_CLASS.valid_input?(nil))
    refute(DESCRIBED_CLASS.valid_input?(1))
    refute(DESCRIBED_CLASS.valid_input?('true'))
  end

  def test_valid_output_ask
    assert(DESCRIBED_CLASS.valid_output?(true))
    assert(DESCRIBED_CLASS.valid_output?(false))
    assert(DESCRIBED_CLASS.valid_output?(nil))
  end

  def test_as_json
    assert(DESCRIBED_CLASS.as_json(true))
    assert(DESCRIBED_CLASS.as_json([1]))
    assert(DESCRIBED_CLASS.as_json([]))
    assert(DESCRIBED_CLASS.as_json('abc'))
    assert(DESCRIBED_CLASS.as_json(''))

    refute(DESCRIBED_CLASS.as_json(nil))
    refute(DESCRIBED_CLASS.as_json(0))
    refute(DESCRIBED_CLASS.as_json('f'))
    refute(DESCRIBED_CLASS.as_json('false'))
  end

  def test_deserialize
    assert(DESCRIBED_CLASS.deserialize(1))
    assert(DESCRIBED_CLASS.deserialize('abc'))
    assert(DESCRIBED_CLASS.deserialize(true))

    refute(DESCRIBED_CLASS.deserialize(0))
    refute(DESCRIBED_CLASS.deserialize(nil))
    refute(DESCRIBED_CLASS.deserialize(false))
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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