core-api/routing: make RouteRef implement ConcreteRoute and use in registry test
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { RouteRefConfig } from './types';
|
||||
import { ConcreteRoute, resolveRoute, RouteRefConfig } from './types';
|
||||
|
||||
export class AbsoluteRouteRef {
|
||||
export class AbsoluteRouteRef implements ConcreteRoute {
|
||||
constructor(private readonly config: RouteRefConfig) {}
|
||||
|
||||
get icon() {
|
||||
@@ -31,6 +31,10 @@ export class AbsoluteRouteRef {
|
||||
get title() {
|
||||
return this.config.title;
|
||||
}
|
||||
|
||||
[resolveRoute](path: string) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
export function createRouteRef(config: RouteRefConfig): AbsoluteRouteRef {
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
|
||||
import { RouteRefRegistry } from './RouteRefRegistry';
|
||||
import { resolveRoute } from './types';
|
||||
import { createRouteRef } from './RouteRef';
|
||||
|
||||
const ref1 = { [resolveRoute]: (path: string) => path };
|
||||
const ref11 = { [resolveRoute]: (path: string) => path };
|
||||
const ref12 = { [resolveRoute]: (path: string) => path };
|
||||
const ref121 = { [resolveRoute]: (path: string) => path };
|
||||
const ref2 = { [resolveRoute]: (path: string) => path };
|
||||
const dummyConfig = { path: '/', icon: null, title: 'my-title' };
|
||||
const ref1 = createRouteRef(dummyConfig);
|
||||
const ref11 = createRouteRef(dummyConfig);
|
||||
const ref12 = createRouteRef(dummyConfig);
|
||||
const ref121 = createRouteRef(dummyConfig);
|
||||
const ref2 = createRouteRef(dummyConfig);
|
||||
|
||||
describe('RouteRefRegistry', () => {
|
||||
it('should be constructed with a root route', () => {
|
||||
|
||||
Reference in New Issue
Block a user