-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f898798
commit 30c4948
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* @flow */ | ||
|
||
import { parse } from 'graphql/language'; | ||
import getDescription from '../getDescription'; | ||
|
||
describe('getDescription()', () => { | ||
const generateNode = description => parse(` | ||
# ${description === undefined ? '' : description} | ||
type Type { | ||
int: Int | ||
} | ||
`).definitions[0]; | ||
|
||
test('gets description', () => { | ||
const description = 'A description.'; | ||
expect(getDescription(generateNode(description))).toBe(description); | ||
}); | ||
|
||
test('returns undefined if there\'s no description', () => { | ||
expect(getDescription(generateNode())).toBeUndefined(); | ||
}); | ||
|
||
test('return undefined if there\'s an empty description', () => { | ||
expect(getDescription(generateNode(' '))).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* @flow */ | ||
|
||
import type { Location } from 'graphql/language'; | ||
import { getDescription } from 'graphql/utilities/buildASTSchema'; | ||
|
||
export default (node: { loc?: Location }) => getDescription(node) || undefined; |