|
2 | 2 | require "spec_helper"
|
3 | 3 |
|
4 | 4 | describe GraphQL::Schema::Member::BuildType do
|
| 5 | + describe ".parse_type" do |
| 6 | + it "resolves a string type from a string" do |
| 7 | + assert_equal GraphQL::Types::String, GraphQL::Schema::Member::BuildType.parse_type("String", null: true) |
| 8 | + end |
| 9 | + |
| 10 | + it "resolves an integer type from a string" do |
| 11 | + assert_equal GraphQL::Types::Int, GraphQL::Schema::Member::BuildType.parse_type("Integer", null: true) |
| 12 | + end |
| 13 | + |
| 14 | + it "resolves a float type from a string" do |
| 15 | + assert_equal GraphQL::Types::Float, GraphQL::Schema::Member::BuildType.parse_type("Float", null: true) |
| 16 | + end |
| 17 | + |
| 18 | + it "resolves a boolean type from a string" do |
| 19 | + assert_equal GraphQL::Types::Boolean, GraphQL::Schema::Member::BuildType.parse_type("Boolean", null: true) |
| 20 | + end |
| 21 | + |
| 22 | + it "resolves an interface type from a string" do |
| 23 | + assert_equal Jazz::BaseInterface, GraphQL::Schema::Member::BuildType.parse_type("Jazz::BaseInterface", null: true) |
| 24 | + end |
| 25 | + |
| 26 | + it "resolves an object type from a class" do |
| 27 | + assert_equal Jazz::BaseObject, GraphQL::Schema::Member::BuildType.parse_type(Jazz::BaseObject, null: true) |
| 28 | + end |
| 29 | + |
| 30 | + it "resolves an object type from a string" do |
| 31 | + assert_equal Jazz::BaseObject, GraphQL::Schema::Member::BuildType.parse_type("Jazz::BaseObject", null: true) |
| 32 | + end |
| 33 | + |
| 34 | + it "resolves a nested object type from a string" do |
| 35 | + assert_equal Jazz::Introspection::NestedType, GraphQL::Schema::Member::BuildType.parse_type("Jazz::Introspection::NestedType", null: true) |
| 36 | + end |
| 37 | + |
| 38 | + it "resolves a deeply nested object type from a string" do |
| 39 | + assert_equal Jazz::Introspection::NestedType::DeeplyNestedType, GraphQL::Schema::Member::BuildType.parse_type("Jazz::Introspection::NestedType::DeeplyNestedType", null: true) |
| 40 | + end |
| 41 | + |
| 42 | + it "resolves a list type from an array of classes" do |
| 43 | + assert_instance_of GraphQL::Schema::List, GraphQL::Schema::Member::BuildType.parse_type([Jazz::BaseObject], null: true) |
| 44 | + end |
| 45 | + |
| 46 | + it "resolves a list type from an array of strings" do |
| 47 | + assert_instance_of GraphQL::Schema::List, GraphQL::Schema::Member::BuildType.parse_type(["Jazz::BaseObject"], null: true) |
| 48 | + end |
| 49 | + end |
| 50 | + |
5 | 51 | describe ".to_type_name" do
|
6 | 52 | it "works with lists and non-nulls" do
|
7 | 53 | t = Class.new(GraphQL::Schema::Object) do
|
|
0 commit comments