@@ -43,8 +43,6 @@ import {
43
43
InjectorProfilerEventType ,
44
44
ProviderConfiguredEvent ,
45
45
setInjectorProfiler ,
46
- injectorProfiler ,
47
- InjectorProfilerContext ,
48
46
} from '../../src/render3/debug/injector_profiler' ;
49
47
import { getNodeInjectorLView , NodeInjector } from '../../src/render3/di' ;
50
48
import {
@@ -77,7 +75,6 @@ describe('setProfiler', () => {
77
75
createEvents = [ ] ;
78
76
providerConfiguredEvents = [ ] ;
79
77
80
- setInjectorProfiler ( null ) ;
81
78
setInjectorProfiler ( ( injectorProfilerEvent : InjectorProfilerEvent ) => {
82
79
const { type} = injectorProfilerEvent ;
83
80
if ( type === InjectorProfilerEventType . Inject ) {
@@ -106,7 +103,7 @@ describe('setProfiler', () => {
106
103
} ) ;
107
104
} ) ;
108
105
109
- afterEach ( ( ) => setInjectorProfiler ( null ) ) ;
106
+ afterAll ( ( ) => setInjectorProfiler ( null ) ) ;
110
107
111
108
it ( 'should emit DI events when a component contains a provider and injects it' , ( ) => {
112
109
class MyService { }
@@ -385,77 +382,7 @@ describe('setProfiler', () => {
385
382
} ) ;
386
383
} ) ;
387
384
388
- describe ( 'profiler activation and removal' , ( ) => {
389
- class SomeClass { }
390
-
391
- const fakeContext : InjectorProfilerContext = {
392
- injector : Injector . create ( { providers : [ ] } ) ,
393
- token : SomeClass ,
394
- } ;
395
-
396
- const fakeEvent : InjectorCreatedInstanceEvent = {
397
- type : InjectorProfilerEventType . InstanceCreatedByInjector ,
398
- context : fakeContext ,
399
- instance : { value : new SomeClass ( ) } ,
400
- } ;
401
-
402
- it ( 'should allow adding and removing multiple profilers' , ( ) => {
403
- const events : string [ ] = [ ] ;
404
- const r1 = setInjectorProfiler ( ( e ) => events . push ( 'P1: ' + e . type ) ) ;
405
- const r2 = setInjectorProfiler ( ( e ) => events . push ( 'P2: ' + e . type ) ) ;
406
-
407
- injectorProfiler ( fakeEvent ) ;
408
- expect ( events ) . toEqual ( [ 'P1: 1' , 'P2: 1' ] ) ;
409
-
410
- r1 ( ) ;
411
- injectorProfiler ( fakeEvent ) ;
412
- expect ( events ) . toEqual ( [ 'P1: 1' , 'P2: 1' , 'P2: 1' ] ) ;
413
-
414
- r2 ( ) ;
415
- injectorProfiler ( fakeEvent ) ;
416
- expect ( events ) . toEqual ( [ 'P1: 1' , 'P2: 1' , 'P2: 1' ] ) ;
417
- } ) ;
418
-
419
- it ( 'should not add / remove the same profiler twice' , ( ) => {
420
- const events : string [ ] = [ ] ;
421
- const p1 = ( e : InjectorProfilerEvent ) => events . push ( 'P1: ' + e . type ) ;
422
- const r1 = setInjectorProfiler ( p1 ) ;
423
- const r2 = setInjectorProfiler ( p1 ) ;
424
-
425
- injectorProfiler ( fakeEvent ) ;
426
- expect ( events ) . toEqual ( [ 'P1: 1' ] ) ;
427
-
428
- r1 ( ) ;
429
- injectorProfiler ( fakeEvent ) ;
430
- expect ( events ) . toEqual ( [ 'P1: 1' ] ) ;
431
-
432
- // subsequent removals should be noop
433
- r1 ( ) ;
434
- r2 ( ) ;
435
- } ) ;
436
-
437
- it ( 'should clear all profilers when passing null' , ( ) => {
438
- const events : string [ ] = [ ] ;
439
- setInjectorProfiler ( ( e ) => events . push ( 'P1: ' + e . type ) ) ;
440
- setInjectorProfiler ( ( e ) => events . push ( 'P2: ' + e . type ) ) ;
441
-
442
- injectorProfiler ( fakeEvent ) ;
443
- expect ( events ) . toEqual ( [ 'P1: 1' , 'P2: 1' ] ) ;
444
-
445
- // clear all profilers
446
- setInjectorProfiler ( null ) ;
447
- injectorProfiler ( fakeEvent ) ;
448
- expect ( events ) . toEqual ( [ 'P1: 1' , 'P2: 1' ] ) ;
449
- } ) ;
450
- } ) ;
451
-
452
385
describe ( 'getInjectorMetadata' , ( ) => {
453
- beforeEach ( ( ) => {
454
- setInjectorProfiler ( null ) ;
455
- setupFrameworkInjectorProfiler ( ) ;
456
- } ) ;
457
- afterEach ( ( ) => setInjectorProfiler ( null ) ) ;
458
-
459
386
it ( 'should be able to determine injector type and name' , fakeAsync ( ( ) => {
460
387
class MyServiceA { }
461
388
@NgModule ( { providers : [ MyServiceA ] } )
@@ -559,11 +486,8 @@ describe('getInjectorMetadata', () => {
559
486
} ) ;
560
487
561
488
describe ( 'getInjectorProviders' , ( ) => {
562
- beforeEach ( ( ) => {
563
- setInjectorProfiler ( null ) ;
564
- setupFrameworkInjectorProfiler ( ) ;
565
- } ) ;
566
- afterEach ( ( ) => setInjectorProfiler ( null ) ) ;
489
+ beforeEach ( ( ) => setupFrameworkInjectorProfiler ( ) ) ;
490
+ afterAll ( ( ) => setInjectorProfiler ( null ) ) ;
567
491
568
492
it ( 'should be able to get the providers from a components injector' , ( ) => {
569
493
class MyService { }
@@ -1028,11 +952,8 @@ describe('getInjectorProviders', () => {
1028
952
} ) ;
1029
953
1030
954
describe ( 'getDependenciesFromInjectable' , ( ) => {
1031
- beforeEach ( ( ) => {
1032
- setInjectorProfiler ( null ) ;
1033
- setupFrameworkInjectorProfiler ( ) ;
1034
- } ) ;
1035
- afterEach ( ( ) => setInjectorProfiler ( null ) ) ;
955
+ beforeEach ( ( ) => setupFrameworkInjectorProfiler ( ) ) ;
956
+ afterAll ( ( ) => setInjectorProfiler ( null ) ) ;
1036
957
1037
958
it ( 'should be able to determine which injector dependencies come from' , fakeAsync ( ( ) => {
1038
959
class MyService { }
@@ -1322,11 +1243,8 @@ describe('getDependenciesFromInjectable', () => {
1322
1243
} ) ;
1323
1244
1324
1245
describe ( 'getInjectorResolutionPath' , ( ) => {
1325
- beforeEach ( ( ) => {
1326
- setInjectorProfiler ( null ) ;
1327
- setupFrameworkInjectorProfiler ( ) ;
1328
- } ) ;
1329
- afterEach ( ( ) => setInjectorProfiler ( null ) ) ;
1246
+ beforeEach ( ( ) => setupFrameworkInjectorProfiler ( ) ) ;
1247
+ afterAll ( ( ) => setInjectorProfiler ( null ) ) ;
1330
1248
1331
1249
it ( 'should be able to inspect injector hierarchy structure' , fakeAsync ( ( ) => {
1332
1250
class MyServiceA { }
0 commit comments