@@ -256,12 +256,50 @@ describe('Angular Tracing', () => {
256
256
257
257
describe ( 'TraceDirective' , ( ) => {
258
258
it ( 'should create an instance' , ( ) => {
259
- const directive = new TraceDirective ( ) ;
259
+ const directive = new TraceDirective ( { } as unknown as any ) ;
260
260
expect ( directive ) . toBeTruthy ( ) ;
261
261
} ) ;
262
262
263
+ it ( 'should create a child tracingSpan on init (WIP)' , async ( ) => {
264
+ const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
265
+
266
+ @Component ( {
267
+ selector : 'app-component' ,
268
+ template : `<app-child trace></app-child>` ,
269
+ } )
270
+ class AppComponent {
271
+ public constructor ( ) { }
272
+ }
273
+
274
+ @Component ( {
275
+ selector : 'app-child' ,
276
+ template : `<p>Hi</p>` ,
277
+ } )
278
+ class ChildComponent {
279
+ public constructor ( ) { }
280
+ }
281
+
282
+ const env = await TestEnv . setup ( {
283
+ components : [ AppComponent , ChildComponent , TraceDirective ] ,
284
+ defaultComponent : AppComponent ,
285
+ customStartTransaction,
286
+ useTraceService : false ,
287
+ } ) ;
288
+
289
+ transaction . startChild = jest . fn ( ) ;
290
+
291
+ //directive.ngOnInit();
292
+
293
+ expect ( transaction . startChild ) . toHaveBeenCalledWith ( {
294
+ op : 'ui.angular.init' ,
295
+ description : '<unknown>' ,
296
+ } ) ;
297
+
298
+ env . destroy ( ) ;
299
+ } ) ;
300
+
263
301
it ( 'should create a child tracingSpan on init' , async ( ) => {
264
- const directive = new TraceDirective ( ) ;
302
+ // const directive = new TraceDirective({} as unknown as any );
265
303
const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
266
304
267
305
const env = await TestEnv . setup ( {
@@ -272,7 +310,7 @@ describe('Angular Tracing', () => {
272
310
273
311
transaction . startChild = jest . fn ( ) ;
274
312
275
- directive . ngOnInit ( ) ;
313
+ // directive.ngOnInit();
276
314
277
315
expect ( transaction . startChild ) . toHaveBeenCalledWith ( {
278
316
op : 'ui.angular.init' ,
@@ -283,7 +321,7 @@ describe('Angular Tracing', () => {
283
321
} ) ;
284
322
285
323
it ( 'should use component name as span description' , async ( ) => {
286
- const directive = new TraceDirective ( ) ;
324
+ const directive = new TraceDirective ( { } as unknown as any ) ;
287
325
const finishMock = jest . fn ( ) ;
288
326
const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
289
327
@@ -309,7 +347,7 @@ describe('Angular Tracing', () => {
309
347
} ) ;
310
348
311
349
it ( 'should finish tracingSpan after view init' , async ( ) => {
312
- const directive = new TraceDirective ( ) ;
350
+ const directive = new TraceDirective ( { } as unknown as any ) ;
313
351
const finishMock = jest . fn ( ) ;
314
352
const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
315
353
0 commit comments