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

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

64 lines
1.5 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Graphql::MountMutation do
let_it_be(:mutation) do
Class.new(Mutations::BaseMutation) do
graphql_name 'TestMutation'
2021-10-27 15:23:28 +05:30
argument :foo, GraphQL::Types::String, required: false
field :bar, GraphQL::Types::String, null: true
2020-07-28 23:09:34 +05:30
end
end
describe '.mount_mutation' do
subject(:field) do
mutation_type = mutation_type_factory do |f|
f.mount_mutation(mutation)
end
2022-05-07 20:08:51 +05:30
mutation_type.get_field('testMutation')
2020-07-28 23:09:34 +05:30
end
it 'mounts a mutation' do
expect(field.mutation).to be_present
end
end
describe '.mount_aliased_mutation' do
subject(:field) do
mutation_type = mutation_type_factory do |f|
f.mount_aliased_mutation('MyAlias', mutation)
end
2022-05-07 20:08:51 +05:30
mutation_type.get_field('myAlias')
2020-07-28 23:09:34 +05:30
end
it 'mounts a mutation' do
expect(field.mutation).to be_present
end
it 'has a correct `graphql_name`' do
expect(field.mutation.graphql_name).to eq('MyAlias')
end
it 'has a correct type' do
2022-05-07 20:08:51 +05:30
expect(field.type.to_type_signature).to eq('MyAliasPayload')
2020-07-28 23:09:34 +05:30
end
it 'has a correct input argument' do
2022-05-07 20:08:51 +05:30
expect(field.arguments['input'].type.unwrap.to_type_signature).to eq('MyAliasInput')
2020-07-28 23:09:34 +05:30
end
end
def mutation_type_factory
Class.new(GraphQL::Schema::Object) do
include Gitlab::Graphql::MountMutation
graphql_name 'MutationType'
yield(self) if block_given?
end
end
end