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
c4226ade
Commit
c4226ade
authored
Feb 19, 2020
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for Gitlab::Graphql::Docs::Renderer
parent
4bda06f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
spec/lib/gitlab/graphql/docs/renderer_spec.rb
spec/lib/gitlab/graphql/docs/renderer_spec.rb
+96
-0
No files found.
spec/lib/gitlab/graphql/docs/renderer_spec.rb
0 → 100644
View file @
c4226ade
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Graphql
::
Docs
::
Renderer
do
describe
'#contents'
do
# Returns a Schema that uses the given `type`
def
mock_schema
(
type
)
query_type
=
Class
.
new
(
GraphQL
::
Schema
::
Object
)
do
graphql_name
'QueryType'
field
:foo
,
type
,
null:
true
end
GraphQL
::
Schema
.
define
(
query:
query_type
)
end
let_it_be
(
:template
)
{
Rails
.
root
.
join
(
'lib/gitlab/graphql/docs/templates/'
,
'default.md.haml'
)
}
subject
(
:contents
)
do
described_class
.
new
(
mock_schema
(
type
).
graphql_definition
,
output_dir:
nil
,
template:
template
).
contents
end
context
'A type with a field with a [Array] return type'
do
let
(
:type
)
do
Class
.
new
(
GraphQL
::
Schema
::
Object
)
do
graphql_name
'ArrayTest'
field
:foo
,
[
GraphQL
::
STRING_TYPE
],
null:
false
,
description:
'A description'
end
end
specify
do
expectation
=
<<~
DOC
## ArrayTest
| Name | Type | Description |
| --- | ---- | ---------- |
| `foo` | String! => Array | A description |
DOC
is_expected
.
to
include
(
expectation
)
end
end
context
'A type with fields defined in reverse alphabetical order'
do
let
(
:type
)
do
Class
.
new
(
GraphQL
::
Schema
::
Object
)
do
graphql_name
'OrderingTest'
field
:foo
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'A description of foo field'
field
:bar
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'A description of bar field'
end
end
specify
do
expectation
=
<<~
DOC
## OrderingTest
| Name | Type | Description |
| --- | ---- | ---------- |
| `bar` | String! | A description of bar field |
| `foo` | String! | A description of foo field |
DOC
is_expected
.
to
include
(
expectation
)
end
end
context
'A type with a deprecated field'
do
let
(
:type
)
do
Class
.
new
(
GraphQL
::
Schema
::
Object
)
do
graphql_name
'DeprecatedTest'
field
:foo
,
GraphQL
::
STRING_TYPE
,
null:
false
,
deprecation_reason:
'This is deprecated'
,
description:
'A description'
end
end
specify
do
expectation
=
<<~
DOC
## DeprecatedTest
| Name | Type | Description |
| --- | ---- | ---------- |
| `foo` **{warning-solid}** | String! | **Deprecated:** This is deprecated |
DOC
is_expected
.
to
include
(
expectation
)
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