2424 */
2525
2626import { TestBed , ComponentFixture } from '@angular/core/testing'
27- import { NgModule , Component , Injectable } from '@angular/core'
28- import { Routes , Router , CanActivate } from '@angular/router'
27+ import { NgModule , Component } from '@angular/core'
28+ import { Routes , Router } from '@angular/router'
2929import { RouterTestingModule } from '@angular/router/testing'
3030import { Location } from '@angular/common'
3131import { ApmBase } from '@elastic/apm-rum'
@@ -77,19 +77,11 @@ class SlugComponent {}
7777} )
7878class AppComponent { }
7979
80- @Injectable ( )
81- class CanActivateFail implements CanActivate {
82- canActivate ( ) : any {
83- throw Error ( 'Navigation failed to activate!!!' )
84- }
85- }
86-
8780const routes : Routes = [
8881 { path : '' , redirectTo : 'home' , pathMatch : 'full' } ,
8982 { path : 'home' , component : HomeComponent } ,
9083 { path : 'lazy' , loadChildren : ( ) => LazyModule } ,
91- { path : 'slug/:id' , component : SlugComponent } ,
92- { path : 'failing' , component : SlugComponent , canActivate : [ CanActivateFail ] }
84+ { path : 'slug/:id' , component : SlugComponent }
9385]
9486
9587describe ( 'ApmService' , ( ) => {
@@ -103,7 +95,7 @@ describe('ApmService', () => {
10395 TestBed . configureTestingModule ( {
10496 imports : [ ApmModule , RouterTestingModule . withRoutes ( routes ) ] ,
10597 declarations : [ HomeComponent , AppComponent , SlugComponent ] ,
106- providers : [ ApmService , CanActivateFail ]
98+ providers : [ ApmService ]
10799 } ) . compileComponents ( )
108100
109101 TestBed . overrideProvider ( APM , {
@@ -263,21 +255,21 @@ describe('ApmService', () => {
263255 const path = location . path ( )
264256 const tr = service . apm . getCurrentTransaction ( )
265257 fixture . ngZone . run ( ( ) => {
266- router . navigate ( [ '/failing ' ] ) . then ( ( ) => {
258+ router . navigate ( [ '/invalid-route ' ] ) . then ( ( ) => {
267259 expect ( location . path ( ) ) . toBe ( path )
268260 expect ( compiled . querySelector ( 'ng-component' ) . textContent ) . toBe (
269261 'Slug'
270262 )
271263 expect ( service . apm . startTransaction ) . toHaveBeenCalledWith (
272- '/failing ' ,
264+ '/invalid-route ' ,
273265 'route-change' ,
274266 {
275267 managed : true ,
276268 canReuse : true
277269 }
278270 )
279271 expect ( service . apm . captureError ) . toHaveBeenCalledWith ( 'error' )
280- expect ( tr . name ) . toEqual ( '/failing ' )
272+ expect ( tr . name ) . toEqual ( '/invalid-route ' )
281273
282274 done ( )
283275 } )
0 commit comments