blob: 7d7e8cdf3870356c0e13e1515d7c6f1d13341ae5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::EchoResolver do
include GraphqlHelpers
let(:current_user) { create(:user) }
let(:text) { 'Message test' }
specify do
expect(described_class.field_options).to include(
type: eq(::GraphQL::STRING_TYPE),
null: be_falsey
)
end
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
|