Sha256: 419a120654d8348112cdbf279a4589883e75ca6cd68683059ff60fd230de05c1

Contents?: true

Size: 885 Bytes

Versions: 35

Compression:

Stored size: 885 Bytes

Contents

require "spec_helper"

describe GraphQL::ListType do
  let(:float_list) { GraphQL::ListType.new(of_type: GraphQL::FLOAT_TYPE) }

  it "coerces elements in the list" do
    assert_equal([1.0, 2.0, 3.0].inspect, float_list.coerce_input([1, 2, 3]).inspect)
  end

  describe "validate_input with bad input" do
    let(:bad_num) { "bad_num" }
    let(:result) { float_list.validate_input([bad_num, 2.0, 3.0]) }

    it "returns an invalid result" do
      assert(!result.valid?)
    end

    it "has one problem" do
      assert_equal(result.problems.length, 1)
    end

    it "has path [0]" do
      assert_equal(result.problems[0]["path"], [0])
    end

    it "has the correct explanation" do
      expected = GraphQL::FLOAT_TYPE.validate_input(bad_num).problems[0]["explanation"]
      actual = result.problems[0]["explanation"]
      assert_equal(actual, expected)
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
graphql-1.0.0 spec/graphql/list_type_spec.rb
graphql-0.19.4 spec/graphql/list_type_spec.rb
graphql-0.19.3 spec/graphql/list_type_spec.rb
graphql-0.19.2 spec/graphql/list_type_spec.rb
graphql-0.19.1 spec/graphql/list_type_spec.rb
graphql-0.19.0 spec/graphql/list_type_spec.rb
graphql-0.18.15 spec/graphql/list_type_spec.rb
graphql-0.18.14 spec/graphql/list_type_spec.rb
graphql-0.18.13 spec/graphql/list_type_spec.rb
graphql-0.18.12 spec/graphql/list_type_spec.rb
graphql-0.18.11 spec/graphql/list_type_spec.rb
graphql-0.18.10 spec/graphql/list_type_spec.rb
graphql-0.18.9 spec/graphql/list_type_spec.rb
graphql-0.18.8 spec/graphql/list_type_spec.rb
graphql-0.18.7 spec/graphql/list_type_spec.rb
graphql-0.18.6 spec/graphql/list_type_spec.rb
graphql-0.18.5 spec/graphql/list_type_spec.rb
graphql-0.18.4 spec/graphql/list_type_spec.rb
graphql-0.18.3 spec/graphql/list_type_spec.rb
graphql-0.18.2 spec/graphql/list_type_spec.rb