WIP - add extractor, generate snippet_data
This commit is contained in:
52
node_modules/gatsby/cache-dir/__tests__/find-path.js
generated
vendored
Normal file
52
node_modules/gatsby/cache-dir/__tests__/find-path.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import { cleanPath, findMatchPath, setMatchPaths } from "../find-path"
|
||||
|
||||
describe(`find-path`, () => {
|
||||
describe(`cleanPath`, () => {
|
||||
beforeEach(() => {
|
||||
global.__BASE_PATH__ = ``
|
||||
})
|
||||
|
||||
it(`should strip out ? & # from a pathname`, () => {
|
||||
expect(cleanPath(`/mypath#anchor?gatsby=cool`)).toBe(`/mypath`)
|
||||
})
|
||||
|
||||
it(`should convert a /index.html to root dir`, () => {
|
||||
expect(cleanPath(`/index.html`)).toBe(`/`)
|
||||
})
|
||||
|
||||
it(`strip out a basePrefix`, () => {
|
||||
global.__BASE_PATH__ = `/blog`
|
||||
expect(cleanPath(`/blog/mypath`)).toBe(`/mypath`)
|
||||
})
|
||||
})
|
||||
|
||||
describe(`findMatchPath`, () => {
|
||||
beforeEach(() => {
|
||||
// reset matchPaths
|
||||
setMatchPaths([])
|
||||
global.__BASE_PATH__ = ``
|
||||
})
|
||||
|
||||
it(`should find a path when matchPath found`, () => {
|
||||
setMatchPaths([
|
||||
{
|
||||
matchPath: `/app/*`,
|
||||
path: `/app`,
|
||||
},
|
||||
])
|
||||
|
||||
expect(findMatchPath(`/app/dynamic-page#anchor?gatsby=cool`)).toBe(`/app`)
|
||||
})
|
||||
|
||||
it(`should return null when no matchPathFound`, () => {
|
||||
setMatchPaths([
|
||||
{
|
||||
matchPath: `/app/*`,
|
||||
path: `/app`,
|
||||
},
|
||||
])
|
||||
|
||||
expect(findMatchPath(`/notanapp/dynamic-page`)).toBeNull()
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user