import { Injectable , Inject , } from '@angular/core' ; import * as faker from '@faker-js/faker/locale/en_US' ; import { Observable , of , throwError , } from 'rxjs' ; import { daffUriTruncateLeadingSlash , daffUriTruncateQueryFragment , } from '@daffodil/core/routing' ; import { DaffExternallyResolvableUrl } from '@daffodil/external-router' ; import { DaffExternalRouterDriverInterface } from '@daffodil/external-router/driver' ; import { DaffExternalRouterDriverTestingConfig , DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG , } from './config' ; inheritdoc see DaffExternalRouterTestingDriver @ Injectable ( { providedIn : 'root' , } ) export class DaffExternalRouterTestingDriver implements DaffExternalRouterDriverInterface { constructor ( @ Inject ( DAFF_EXTERNAL_ROUTER_DRIVER_TESTING_CONFIG ) private testingConfiguration = { } ) { } resolve ( url ) { const truncatedUrl = daffUriTruncateLeadingSlash ( daffUriTruncateQueryFragment ( url ) ) ; if ( ! this . testingConfiguration [ truncatedUrl ] ) { return throwError ( `\
The route '${ truncatedUrl }' wasn't provided with a matching type by the testing driver. \
Did you configure the available route types with DaffExternalRouterDriverTestingModule.forRoot(config)` ) ; } return of ( { id : faker . datatype . uuid ( ) , url : truncatedUrl , type : this . testingConfiguration [ truncatedUrl ] , code : 200 , } ) ; } }