routeComponentPropsFixture.ts 680 B

12345678910111213141516171819
  1. import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
  2. import {RouterFixture} from 'sentry-fixture/routerFixture';
  3. export function RouteComponentPropsFixture<
  4. QueryParams extends {[key: string]: string | undefined},
  5. RouteParams extends {[key: string]: string | undefined},
  6. >(
  7. params: Partial<RouteComponentProps<QueryParams, RouteParams>> = {}
  8. ): RouteComponentProps<QueryParams, RouteParams> {
  9. const router = RouterFixture(params);
  10. return {
  11. location: router.location,
  12. params: router.params as QueryParams & RouteParams,
  13. routes: router.routes,
  14. route: router.routes[0],
  15. routeParams: router.params as RouteParams,
  16. router,
  17. };
  18. }