Sha256: ed5bbb00b2f2d567ffd25f6164d3d152c4e49bae43cb95d9afcc80f047cc3466
Contents?: true
Size: 1.51 KB
Versions: 24
Compression:
Stored size: 1.51 KB
Contents
require "spec_helper" describe GraphQL::ObjectType do let(:type) { CheeseType } it "has a name" do assert_equal("Cheese", type.name) type.name = "Fromage" assert_equal("Fromage", type.name) type.name = "Cheese" end it "has a description" do assert_equal(22, type.description.length) end it "may have interfaces" do assert_equal([EdibleInterface, AnimalProductInterface, LocalProductInterface], type.interfaces) end it "accepts fields definition" do last_produced_dairy = GraphQL::Field.define(name: :last_produced_dairy, type: DairyProductUnion) cow_type = GraphQL::ObjectType.define(name: "Cow", fields: [last_produced_dairy]) assert_equal([last_produced_dairy], cow_type.fields) end describe '#get_field ' do it "exposes fields" do field = type.get_field("id") assert_equal(GraphQL::TypeKinds::NON_NULL, field.type.kind) assert_equal(GraphQL::TypeKinds::SCALAR, field.type.of_type.kind) end it "exposes defined field property" do field_without_prop = CheeseType.get_field("flavor") field_with_prop = CheeseType.get_field("fatContent") assert_equal(field_without_prop.property, nil) assert_equal(field_with_prop.property, :fat_content) end it "looks up from interfaces" do field_from_self = CheeseType.get_field("fatContent") field_from_iface = MilkType.get_field("fatContent") assert_equal(field_from_self.property, :fat_content) assert_equal(field_from_iface.property, nil) end end end
Version data entries
24 entries across 24 versions & 1 rubygems