-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from maxholman/interpolate
Named route path interpolation and hook navigation fixes
- Loading branch information
Showing
22 changed files
with
942 additions
and
906 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import '@testing-library/jest-dom'; | ||
import { interpolate } from '../lib/named-route.js'; | ||
|
||
// type PathPart = `/${string}`; | ||
// type Path = `${PathPart}${PathPart}?` | `${PathPart}${PathPart}*`; | ||
|
||
test('custom route', async () => { | ||
expect(interpolate('/test', {})).toBe('/test'); | ||
|
||
expect( | ||
interpolate('/foo/:foo', { | ||
foo: 'oof', | ||
}), | ||
).toBe('/foo/oof'); | ||
|
||
expect( | ||
interpolate('/foo/:foo?', { | ||
foo: 'oof', | ||
}), | ||
).toBe('/foo/oof'); | ||
|
||
expect(interpolate('/foo/:foo?', {})).toBe('/foo'); | ||
expect( | ||
interpolate('/foo/:foo?/bar/:bar', { | ||
bar: 'rab', | ||
}), | ||
).toBe('/foo/bar/rab'); | ||
|
||
expect( | ||
interpolate('/foo/:foo*', { | ||
foo: 'oof', | ||
}), | ||
).toBe('/foo/oof'); | ||
|
||
expect( | ||
interpolate('/foo/:foo+', { | ||
foo: 'oof', | ||
}), | ||
).toBe('/foo/oof'); | ||
|
||
expect( | ||
interpolate('/foo/:foo*', { | ||
foo: 'oof/rab/zab', | ||
}), | ||
).toBe('/foo/oof/rab/zab'); | ||
expect( | ||
interpolate('/set/:set/q/:id?', { | ||
set: 'BTT', | ||
id: 'YES!', | ||
}), | ||
).toBe('/set/BTT/q/YES!'); | ||
}); |
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.