-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixes regression with pathPrefix and gatsby-link
Note: this is not done! Want to get the tests actually working
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
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
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 @@ | ||
import React from 'react'; | ||
|
||
const getInstance = (to, pathPrefix = '') => { | ||
if (pathPrefix) { | ||
global.__PREFIX_PATHS__ = true; | ||
global.__PATH_PREFIX__ = pathPrefix; | ||
} else { | ||
global.__PREFIX_PATHS__ = false; | ||
} | ||
const Link = require('../').default; | ||
return new Link({ | ||
to | ||
}); | ||
}; | ||
|
||
test('it does not prefix paths by default', () => { | ||
const instance = getInstance('/some-path'); | ||
|
||
expect(instance.state.to).toBe('/some-path'); | ||
}); | ||
|
||
test.skip('it prefixes paths if __PREFIX_PATHS__ and __PATH_PREFIX__ are defined', () => { | ||
const instance = getInstance('/some-path', '/blog'); | ||
|
||
expect(instance.state.to).toBe('/blog/some-path'); | ||
}); |
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