summaryrefslogtreecommitdiff
path: root/spec/graphql/types/range_input_type_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /spec/graphql/types/range_input_type_spec.rb
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
downloadgitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/graphql/types/range_input_type_spec.rb')
-rw-r--r--spec/graphql/types/range_input_type_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/graphql/types/range_input_type_spec.rb b/spec/graphql/types/range_input_type_spec.rb
new file mode 100644
index 00000000000..aa6fd72cf13
--- /dev/null
+++ b/spec/graphql/types/range_input_type_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe ::Types::RangeInputType do
+ let(:of_integer) { ::GraphQL::INT_TYPE }
+
+ context 'parameterized on Integer' do
+ let(:type) { described_class[of_integer] }
+
+ it 'accepts start and end' do
+ input = { start: 1, end: 10 }
+ output = { start: 1, end: 10 }
+
+ expect(type.coerce_isolated_input(input)).to eq(output)
+ end
+
+ it 'rejects inverted ranges' do
+ input = { start: 10, end: 1 }
+
+ expect { type.coerce_isolated_input(input) }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
+ end
+ end
+
+ it 'follows expected subtyping relationships for instances' do
+ context = GraphQL::Query::Context.new(
+ query: OpenStruct.new(schema: nil),
+ values: {},
+ object: nil
+ )
+ instance = described_class[of_integer].new(context: context, defaults_used: [], ruby_kwargs: {})
+
+ expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a_kind_of(described_class[of_integer])
+ expect(instance).not_to be_a_kind_of(described_class[GraphQL::ID_TYPE])
+ end
+
+ it 'follows expected subtyping relationships for classes' do
+ expect(described_class[of_integer]).to be < described_class
+ expect(described_class[of_integer]).not_to be < described_class[GraphQL::ID_TYPE]
+ expect(described_class[of_integer]).not_to be < described_class[of_integer, false]
+ end
+end