debian-mirror-gitlab/spec/lib/gitlab/graphql/negatable_arguments_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.5 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Graphql::NegatableArguments do
let(:test_resolver) do
Class.new(Resolvers::BaseResolver).tap do |klass|
klass.extend described_class
allow(klass).to receive(:name).and_return('Resolvers::TestResolver')
end
end
describe '#negated' do
it 'defines :not argument' do
test_resolver.negated {}
expect(test_resolver.arguments['not'].type.name).to eq "Types::TestResolverNegatedParamsType"
end
it 'defines any arguments passed as block' do
test_resolver.negated do
2021-10-27 15:23:28 +05:30
argument :foo, GraphQL::Types::String, required: false
2021-04-29 21:17:54 +05:30
end
expect(test_resolver.arguments['not'].type.arguments.keys).to match_array(['foo'])
end
2022-07-23 23:45:48 +05:30
# TODO: suffers from the `DuplicateNamesError` error. skip until we upgrade
# to the graphql 2.0 gem https://gitlab.com/gitlab-org/gitlab/-/issues/363131
xit 'defines all arguments passed as block even if called multiple times' do
2021-04-29 21:17:54 +05:30
test_resolver.negated do
2021-10-27 15:23:28 +05:30
argument :foo, GraphQL::Types::String, required: false
2021-04-29 21:17:54 +05:30
end
test_resolver.negated do
2021-10-27 15:23:28 +05:30
argument :bar, GraphQL::Types::String, required: false
2021-04-29 21:17:54 +05:30
end
expect(test_resolver.arguments['not'].type.arguments.keys).to match_array(%w[foo bar])
end
it 'allows to specify custom argument name' do
test_resolver.negated(param_key: :negative) {}
expect(test_resolver.arguments).to include('negative')
end
end
end