Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bbb83096
Commit
bbb83096
authored
Sep 26, 2019
by
Arun Kumar Mohan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for API::Helpers::GraphqlHelpers
parent
d31c908b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
spec/lib/api/helpers/graphql_helpers_spec.rb
spec/lib/api/helpers/graphql_helpers_spec.rb
+44
-0
No files found.
spec/lib/api/helpers/graphql_helpers_spec.rb
0 → 100644
View file @
bbb83096
# frozen_string_literal: true
require
'spec_helper'
describe
API
::
Helpers
::
GraphqlHelpers
do
describe
'run_graphql!'
do
let
(
:query
)
{
'{ metadata { version } }'
}
let
(
:graphql_helper
)
do
Class
.
new
do
include
API
::
Helpers
::
GraphqlHelpers
end
.
new
end
context
'when transform function is provided'
do
let
(
:result
)
{
{
'data'
=>
{
'metadata'
=>
{
'version'
=>
'1.0.0'
}
}
}
}
before
do
allow
(
GitlabSchema
).
to
receive
(
:execute
).
and_return
(
result
)
end
it
'returns the expected result'
do
expect
(
graphql_helper
.
run_graphql!
(
query:
query
,
transform:
->
(
result
)
{
result
.
dig
(
'data'
,
'metadata'
)
}
)
).
to
eq
({
'version'
=>
'1.0.0'
})
end
end
context
'when a transform function is not provided'
do
let
(
:result
)
{
double
(
'result'
)
}
before
do
allow
(
GitlabSchema
).
to
receive
(
:execute
).
and_return
(
result
)
end
it
'returns the expected result'
do
expect
(
graphql_helper
.
run_graphql!
(
query:
query
)).
to
eq
(
result
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment