Files
Andrew Scott 0142ae1c8e refactor(router): Update tests to not use deprecated string tokens (#60378)
This replaces string tokens in the router tests with functional guads.

PR Close #60378
2025-03-28 11:50:11 +00:00

51 lines
1.2 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Type} from '@angular/core';
import {Data, ResolveData, Route} from '../src/models';
import {ActivatedRouteSnapshot} from '../src/router_state';
import {Params} from '../src/shared';
import {UrlSegment, UrlTree} from '../src/url_tree';
export class Logger {
logs: string[] = [];
add(thing: string) {
this.logs.push(thing);
}
empty() {
this.logs.length = 0;
}
}
export declare type ARSArgs = {
url?: UrlSegment[];
params?: Params;
queryParams?: Params;
fragment?: string;
data?: Data;
outlet?: string;
component: Type<unknown> | string | null;
routeConfig?: Route | null;
resolve?: ResolveData;
};
export function createActivatedRouteSnapshot(args: ARSArgs): ActivatedRouteSnapshot {
return new (ActivatedRouteSnapshot as any)(
args.url || [],
args.params || {},
args.queryParams || null,
args.fragment || null,
args.data || null,
args.outlet || null,
args.component,
args.routeConfig || {},
args.resolve || {},
);
}