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(gatsby-plugin-create-client-paths): set matchPath correctly (gats…
…byjs#15014) * Add (failing) tests * Don't short circuit early * Fix README
- Loading branch information
1 parent
60d7e33
commit 3319613
Showing
3 changed files
with
50 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
packages/gatsby-plugin-create-client-paths/src/__tests__/gatsby-node.js
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,48 @@ | ||
const { onCreatePage } = require(`../gatsby-node`) | ||
|
||
describe(`onCreatePage`, () => { | ||
let createPage | ||
|
||
beforeEach(() => { | ||
createPage = jest.fn() | ||
}) | ||
|
||
afterEach(() => { | ||
createPage.mockRestore() | ||
}) | ||
|
||
it(`calls createPage with correct matchPath`, () => { | ||
onCreatePage( | ||
{ | ||
page: { | ||
path: `/app/`, | ||
matchPath: undefined, | ||
}, | ||
actions: { | ||
createPage, | ||
}, | ||
}, | ||
{ prefixes: [`/*`, `/app/*`] } | ||
) | ||
expect(createPage).toHaveBeenCalledWith({ | ||
matchPath: `/app/*`, | ||
path: `/app/`, | ||
}) | ||
}) | ||
|
||
it(`doesn't set matchPath if already set`, () => { | ||
onCreatePage( | ||
{ | ||
page: { | ||
path: `/app/`, | ||
matchPath: `/app/*`, | ||
}, | ||
actions: { | ||
createPage, | ||
}, | ||
}, | ||
{ prefixes: [`/*`, `/app/*`] } | ||
) | ||
expect(createPage).toHaveBeenCalledTimes(0) | ||
}) | ||
}) |
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