gitlab-org--gitlab-foss/spec/graphql/resolvers/echo_resolver_spec.rb
Brett Walker bdd5b5b695 Replace echo function with a resolver
The `GraphQL::Function` has been deprecated in
favor of resolvers.
2019-08-26 17:43:38 +00:00

24 lines
636 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Resolvers::EchoResolver do
include GraphqlHelpers
let(:current_user) { create(:user) }
let(:text) { 'Message test' }
describe '#resolve' do
it 'echoes text and username' do
expect(resolve_echo(text)).to eq %Q("#{current_user.username}" says: #{text})
end
it 'echoes text and nil as username' do
expect(resolve_echo(text, { current_user: nil })).to eq "nil says: #{text}"
end
end
def resolve_echo(text, context = { current_user: current_user })
resolve(described_class, obj: nil, args: { text: text }, ctx: context)
end
end