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
37a0205d
Commit
37a0205d
authored
Nov 24, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for graphql_dig_at
parent
ed4b0fe3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
spec/support_specs/helpers/graphql_helpers_spec.rb
spec/support_specs/helpers/graphql_helpers_spec.rb
+35
-0
No files found.
spec/support_specs/helpers/graphql_helpers_spec.rb
View file @
37a0205d
...
...
@@ -10,6 +10,41 @@ RSpec.describe GraphqlHelpers do
query
.
tr
(
"
\n
"
,
' '
).
gsub
(
/\s+/
,
' '
).
strip
end
describe
'graphql_dig_at'
do
it
'transforms symbol keys to graphql field names'
do
data
=
{
'camelCased'
=>
'names'
}
expect
(
graphql_dig_at
(
data
,
:camel_cased
)).
to
eq
(
'names'
)
end
it
'supports integer indexing'
do
data
=
{
'array'
=>
[
:boom
,
{
'id'
=>
:hooray!
},
:boom
]
}
expect
(
graphql_dig_at
(
data
,
:array
,
1
,
:id
)).
to
eq
(
:hooray!
)
end
it
'gracefully degrades to nil'
do
data
=
{
'project'
=>
{
'mergeRequest'
=>
nil
}
}
expect
(
graphql_dig_at
(
data
,
:project
,
:merge_request
,
:id
)).
to
be_nil
end
it
'supports implicitly flat-mapping traversals'
do
data
=
{
'foo'
=>
{
'nodes'
=>
[
{
'bar'
=>
{
'nodes'
=>
[{
'id'
=>
1
},
{
'id'
=>
2
}]
}
},
{
'bar'
=>
{
'nodes'
=>
[{
'id'
=>
3
},
{
'id'
=>
4
}]
}
},
{
'bar'
=>
nil
}
]
},
'irrelevant'
=>
'the field is a red-herring'
}
expect
(
graphql_dig_at
(
data
,
:foo
,
:nodes
,
:bar
,
:nodes
,
:id
)).
to
eq
([
1
,
2
,
3
,
4
])
end
end
describe
'var'
do
it
'allocates a fresh name for each var'
do
a
=
var
(
'Int'
)
...
...
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