File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ /* @flow */
2+
3+ import { parse } from 'graphql/language' ;
4+ import getDescription from '../getDescription' ;
5+
6+ describe ( 'getDescription()' , ( ) => {
7+ const generateNode = description => parse ( `
8+ # ${ description === undefined ? '' : description }
9+ type Type {
10+ int: Int
11+ }
12+ ` ) . definitions [ 0 ] ;
13+
14+ test ( 'gets description' , ( ) => {
15+ const description = 'A description.' ;
16+ expect ( getDescription ( generateNode ( description ) ) ) . toBe ( description ) ;
17+ } ) ;
18+
19+ test ( 'returns undefined if there\'s no description' , ( ) => {
20+ expect ( getDescription ( generateNode ( ) ) ) . toBeUndefined ( ) ;
21+ } ) ;
22+
23+ test ( 'return undefined if there\'s an empty description' , ( ) => {
24+ expect ( getDescription ( generateNode ( ' ' ) ) ) . toBeUndefined ( ) ;
25+ } ) ;
26+ } ) ;
Original file line number Diff line number Diff line change 1+ /* @flow */
2+
3+ import type { Location } from 'graphql/language' ;
4+ import { getDescription } from 'graphql/utilities/buildASTSchema' ;
5+
6+ export default ( node : { loc ?: Location } ) => getDescription ( node ) || undefined ;
You can’t perform that action at this time.
0 commit comments