@@ -78,7 +78,7 @@ describe('injectQuery', () => {
78
78
const withResultInfer = TestBed . runInInjectionContext ( ( ) =>
79
79
injectQuery ( ( ) => ( {
80
80
queryKey : key ,
81
- queryFn : async ( ) => true ,
81
+ queryFn : ( ) => true ,
82
82
} ) ) ,
83
83
)
84
84
expectTypeOf ( withResultInfer . data ( ) ) . toEqualTypeOf < boolean | undefined > ( )
@@ -263,8 +263,6 @@ describe('injectQuery', () => {
263
263
expect ( query . isFetching ( ) ) . toBe ( true )
264
264
expect ( query . isStale ( ) ) . toBe ( true )
265
265
expect ( query . isFetched ( ) ) . toBe ( false )
266
-
267
- flush ( )
268
266
} ) )
269
267
270
268
test ( 'should resolve to success and update signal: injectQuery()' , fakeAsync ( ( ) => {
@@ -275,7 +273,7 @@ describe('injectQuery', () => {
275
273
} ) )
276
274
} )
277
275
278
- flush ( )
276
+ tick ( )
279
277
280
278
expect ( query . status ( ) ) . toBe ( 'success' )
281
279
expect ( query . data ( ) ) . toBe ( 'result2' )
@@ -294,7 +292,7 @@ describe('injectQuery', () => {
294
292
} ) )
295
293
} )
296
294
297
- flush ( )
295
+ tick ( )
298
296
299
297
expect ( query . status ( ) ) . toBe ( 'error' )
300
298
expect ( query . data ( ) ) . toBe ( undefined )
@@ -316,7 +314,7 @@ describe('injectQuery', () => {
316
314
queryFn : spy ,
317
315
} ) )
318
316
} )
319
- flush ( )
317
+ tick ( )
320
318
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
321
319
322
320
expect ( query . status ( ) ) . toBe ( 'success' )
@@ -331,7 +329,6 @@ describe('injectQuery', () => {
331
329
queryKey : [ 'key8' ] ,
332
330
signal : expect . anything ( ) ,
333
331
} )
334
- flush ( )
335
332
} ) )
336
333
337
334
test ( 'should only run query once enabled signal is set to true' , fakeAsync ( ( ) => {
@@ -350,8 +347,7 @@ describe('injectQuery', () => {
350
347
expect ( query . status ( ) ) . toBe ( 'pending' )
351
348
352
349
enabled . set ( true )
353
- TestBed . flushEffects ( )
354
- flush ( )
350
+ tick ( )
355
351
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
356
352
expect ( query . status ( ) ) . toBe ( 'success' )
357
353
} ) )
@@ -381,7 +377,6 @@ describe('injectQuery', () => {
381
377
expect ( dependentQueryFn ) . not . toHaveBeenCalled ( )
382
378
383
379
tick ( )
384
- TestBed . flushEffects ( )
385
380
386
381
expect ( query1 . data ( ) ) . toStrictEqual ( 'Some data' )
387
382
expect ( query2 . fetchStatus ( ) ) . toStrictEqual ( 'fetching' )
@@ -419,7 +414,7 @@ describe('injectQuery', () => {
419
414
)
420
415
} )
421
416
422
- flush ( )
417
+ tick ( )
423
418
424
419
keySignal . set ( 'key12' )
425
420
@@ -433,8 +428,6 @@ describe('injectQuery', () => {
433
428
} ) ,
434
429
)
435
430
} )
436
-
437
- flush ( )
438
431
} ) )
439
432
440
433
describe ( 'throwOnError' , ( ) => {
@@ -471,7 +464,6 @@ describe('injectQuery', () => {
471
464
expect ( ( ) => {
472
465
flush ( )
473
466
} ) . toThrowError ( 'Some error' )
474
- flush ( )
475
467
} ) )
476
468
477
469
test ( 'should throw when throwOnError function returns true' , fakeAsync ( ( ) => {
@@ -486,7 +478,6 @@ describe('injectQuery', () => {
486
478
expect ( ( ) => {
487
479
flush ( )
488
480
} ) . toThrowError ( 'Some error' )
489
- flush ( )
490
481
} ) )
491
482
} )
492
483
@@ -501,12 +492,12 @@ describe('injectQuery', () => {
501
492
502
493
expect ( query . status ( ) ) . toBe ( 'pending' )
503
494
504
- flush ( )
495
+ tick ( )
505
496
506
497
expect ( query . status ( ) ) . toBe ( 'error' )
507
498
} ) )
508
499
509
- test ( 'should render with required signal inputs' , fakeAsync ( async ( ) => {
500
+ test ( 'should render with required signal inputs' , fakeAsync ( ( ) => {
510
501
@Component ( {
511
502
selector : 'app-fake' ,
512
503
template : `{{ query.data() }}` ,
@@ -517,7 +508,7 @@ describe('injectQuery', () => {
517
508
518
509
query = injectQuery ( ( ) => ( {
519
510
queryKey : [ 'fake' , this . name ( ) ] ,
520
- queryFn : ( ) => Promise . resolve ( this . name ( ) ) ,
511
+ queryFn : ( ) => this . name ( ) ,
521
512
} ) )
522
513
}
523
514
@@ -526,10 +517,10 @@ describe('injectQuery', () => {
526
517
name : 'signal-input-required-test' ,
527
518
} )
528
519
529
- flush ( )
530
520
fixture . detectChanges ( )
521
+ tick ( )
531
522
532
- expect ( fixture . debugElement . nativeElement . textContent ) . toEqual (
523
+ expect ( fixture . componentInstance . query . data ( ) ) . toEqual (
533
524
'signal-input-required-test' ,
534
525
)
535
526
} ) )
@@ -565,13 +556,13 @@ describe('injectQuery', () => {
565
556
566
557
const fixture = TestBed . createComponent ( FakeComponent )
567
558
fixture . detectChanges ( )
568
- flush ( )
559
+ tick ( )
569
560
570
561
expect ( fixture . componentInstance . query . data ( ) ) . toEqual ( 'test name' )
571
562
572
563
fixture . componentInstance . name . set ( 'test name 2' )
573
564
fixture . detectChanges ( )
574
- flush ( )
565
+ tick ( )
575
566
576
567
expect ( fixture . componentInstance . query . data ( ) ) . toEqual ( 'test name 2' )
577
568
} ) )
@@ -608,13 +599,13 @@ describe('injectQuery', () => {
608
599
609
600
const fixture = TestBed . createComponent ( FakeComponent )
610
601
fixture . detectChanges ( )
611
- flush ( )
602
+ tick ( )
612
603
613
604
expect ( fixture . componentInstance . query . data ( ) ) . toEqual ( 'test name' )
614
605
615
606
fixture . componentInstance . name . set ( 'test name 2' )
616
607
fixture . detectChanges ( )
617
- flush ( )
608
+ tick ( )
618
609
619
610
expect ( fixture . componentInstance . query . data ( ) ) . toEqual ( 'test name 2' )
620
611
} ) )
0 commit comments