-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Components: Add support for named arguments in the navigator componen…
…ts (#47827) * Components: Add support for named arguments in the navigator components * Refactor to use useMemo * Improve the types * Switch to React's useId * Refactor how we store the focus target * Add unit tests * Add changelog entry * Rename the Screen type * Improve the types of the params argument * Add unit test * Early return * Add documentation
- Loading branch information
1 parent
79b9fde
commit 8406acf
Showing
12 changed files
with
258 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,50 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { patternMatch } from '../utils/router'; | ||
|
||
describe( 'patternMatch', () => { | ||
it( 'should return undefined if not pattern is matched', () => { | ||
const result = patternMatch( '/test', [ { id: 'route', path: '/' } ] ); | ||
expect( result ).toBeUndefined(); | ||
} ); | ||
|
||
it( 'should match a pattern with no params', () => { | ||
const result = patternMatch( '/test', [ | ||
{ id: 'route', path: '/test' }, | ||
] ); | ||
expect( result ).toEqual( { id: 'route', params: {} } ); | ||
} ); | ||
|
||
it( 'should match a pattern with params', () => { | ||
const result = patternMatch( '/test/123', [ | ||
{ id: 'route', path: '/test/:id' }, | ||
] ); | ||
expect( result ).toEqual( { id: 'route', params: { id: '123' } } ); | ||
} ); | ||
|
||
it( 'should match the first pattern in case of ambiguity', () => { | ||
const result = patternMatch( '/test/123', [ | ||
{ id: 'route1', path: '/test/:id' }, | ||
{ id: 'route2', path: '/test/123' }, | ||
] ); | ||
expect( result ).toEqual( { id: 'route1', params: { id: '123' } } ); | ||
} ); | ||
|
||
it( 'should match a pattern with optional params', () => { | ||
const result = patternMatch( '/test', [ | ||
{ id: 'route', path: '/test/:id?' }, | ||
] ); | ||
expect( result ).toEqual( { id: 'route', params: {} } ); | ||
} ); | ||
|
||
it( 'should return an array of matches for the same param', () => { | ||
const result = patternMatch( '/some/basic/route', [ | ||
{ id: 'route', path: '/:test+' }, | ||
] ); | ||
expect( result ).toEqual( { | ||
id: 'route', | ||
params: { test: [ 'some', 'basic', 'route' ] }, | ||
} ); | ||
} ); | ||
} ); |
Oops, something went wrong.
8406acf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 8406acf.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4132377688
📝 Reported issues:
specs/editor/blocks/heading.test.js
specs/editor/various/multi-block-selection.test.js
specs/editor/various/multi-block-selection.test.js