forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent invalid graphql field names from being created
Note: This will currently transform (for example) `/*` into `_` so I'm not quite sure what the best course of action is to replace that Fixes gatsbyjs#3487; Fixes gatsbyjs#2925
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 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,24 @@ | ||
const createKey = require(`../create-key`) | ||
|
||
describe(`createKey`, () => { | ||
it(`leaves valid strings as is`, () => { | ||
;[ | ||
[`01234`, `01234`], | ||
[`description`, `description`], | ||
[`_hello`, `_hello`], | ||
].forEach(([input, output]) => { | ||
expect(createKey(input)).toBe(output) | ||
}) | ||
}) | ||
|
||
it(`replaces invalid characters`, () => { | ||
;[ | ||
[`/hello`, `_hello`], | ||
[`~/path/to/some/module`, `_path_to_some_module`], | ||
[`/*`, `_`], | ||
[`/*.js`, `_js`], | ||
].forEach(([input, output]) => { | ||
expect(createKey(input)).toBe(output) | ||
}) | ||
}) | ||
}) |
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
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