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.
chore(gatsby-plugin-page-creator): Standardize error reporting text (g…
…atsbyjs#26373) * chore(gatsby-plugin-page-creator): Standardize error reporting to simplify analytics * fix tests and stop crashing at times and crash the build at other times * Fix lint * Thread reporter through functions instead of importing from gatsby-cli * fix lint Co-authored-by: Sidhartha Chatterjee <me@sidharthachatterjee.com>
- Loading branch information
1 parent
3c19438
commit 2771534
Showing
13 changed files
with
264 additions
and
160 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
33 changes: 23 additions & 10 deletions
33
packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts
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 |
---|---|---|
@@ -1,31 +1,44 @@ | ||
import { derivePath } from "../derive-path" | ||
import reporter from "gatsby-cli/lib/reporter" | ||
|
||
describe(`derive-path`, () => { | ||
it(`has basic support`, () => { | ||
expect(derivePath(`product/{Product.id}.js`, { id: `1` })).toEqual( | ||
`product/1` | ||
) | ||
expect( | ||
derivePath(`product/{Product.id}.js`, { id: `1` }, reporter) | ||
).toEqual(`product/1`) | ||
}) | ||
|
||
it(`has nested value support`, () => { | ||
expect( | ||
derivePath(`product/{Product.field__id}.js`, { field: { id: `1` } }) | ||
derivePath( | ||
`product/{Product.field__id}.js`, | ||
{ field: { id: `1` } }, | ||
reporter | ||
) | ||
).toEqual(`product/1`) | ||
}) | ||
|
||
it(`has union support`, () => { | ||
expect( | ||
derivePath(`product/{Product.field__(File)__id}.js`, { | ||
field: { id: `1` }, | ||
}) | ||
derivePath( | ||
`product/{Product.field__(File)__id}.js`, | ||
{ | ||
field: { id: `1` }, | ||
}, | ||
reporter | ||
) | ||
).toEqual(`product/1`) | ||
}) | ||
|
||
it(`doesnt remove '/' from slug`, () => { | ||
expect( | ||
derivePath(`product/{Product.slug}.js`, { | ||
slug: `bar/baz`, | ||
}) | ||
derivePath( | ||
`product/{Product.slug}.js`, | ||
{ | ||
slug: `bar/baz`, | ||
}, | ||
reporter | ||
) | ||
).toEqual(`product/bar/baz`) | ||
}) | ||
}) |
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
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
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
Oops, something went wrong.