Skip to content

Commit 008fd20

Browse files
author
jane-olszewska
committed
Added test for adding a schema element description in comments
1 parent 060dc51 commit 008fd20

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/Language/SchemaParserTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,47 @@ public function testSimpleInputObjectWithArgsShouldFail()
614614
Parser::parse($body);
615615
}
616616

617+
/**
618+
* @it Simple type
619+
*/
620+
public function testSimpleTypeDescriptionInComments()
621+
{
622+
$body = '
623+
# This is a simple type description.
624+
# It is multiline *and includes formatting*.
625+
type Hello {
626+
# And this is a field description
627+
world: String
628+
}';
629+
$doc = Parser::parse($body);
630+
$loc = function($start, $end) {return TestUtils::locArray($start, $end);};
631+
632+
$fieldNode = $this->fieldNode(
633+
$this->nameNode('world', $loc(134, 139)),
634+
$this->typeNode('String', $loc(141, 147)),
635+
$loc(134, 147)
636+
);
637+
$fieldNode['description'] = " And this is a field description\n";
638+
$expected = [
639+
'kind' => NodeKind::DOCUMENT,
640+
'definitions' => [
641+
[
642+
'kind' => NodeKind::OBJECT_TYPE_DEFINITION,
643+
'name' => $this->nameNode('Hello', $loc(88, 93)),
644+
'interfaces' => [],
645+
'directives' => [],
646+
'fields' => [
647+
$fieldNode
648+
],
649+
'loc' => $loc(83, 149),
650+
'description' => " This is a simple type description.\n It is multiline *and includes formatting*.\n"
651+
]
652+
],
653+
'loc' => $loc(0, 149)
654+
];
655+
$this->assertEquals($expected, TestUtils::nodeToArray($doc));
656+
}
657+
617658
private function typeNode($name, $loc)
618659
{
619660
return [

0 commit comments

Comments
 (0)