1
1
import { DataSource } from '@angular/cdk/collections' ;
2
- import { LEFT_ARROW , UP_ARROW , RIGHT_ARROW , DOWN_ARROW , TAB } from '@angular/cdk/keycodes' ;
3
- import { MatTableModule } from '@angular/material/table' ;
4
- import { dispatchKeyboardEvent } from '../../cdk/testing/private' ;
2
+ import { DOWN_ARROW , LEFT_ARROW , RIGHT_ARROW , TAB , UP_ARROW } from '@angular/cdk/keycodes' ;
5
3
import { CommonModule } from '@angular/common' ;
6
- import {
7
- Component ,
8
- Directive ,
9
- ElementRef ,
10
- ViewChild ,
11
- provideZoneChangeDetection ,
12
- } from '@angular/core' ;
13
- import { ComponentFixture , fakeAsync , flush , TestBed , tick } from '@angular/core/testing' ;
4
+ import { Component , Directive , ElementRef , ViewChild } from '@angular/core' ;
5
+ import { ComponentFixture , TestBed , fakeAsync , flush , tick } from '@angular/core/testing' ;
14
6
import { FormsModule , NgForm } from '@angular/forms' ;
7
+ import { MatTableModule } from '@angular/material/table' ;
15
8
import { BehaviorSubject } from 'rxjs' ;
9
+ import { dispatchKeyboardEvent } from '../../cdk/testing/private' ;
16
10
17
11
import {
18
12
CdkPopoverEditColspan ,
19
- HoverContentState ,
20
13
FormValueContainer ,
14
+ HoverContentState ,
21
15
PopoverEditClickOutBehavior ,
22
16
} from '@angular/cdk-experimental/popover-edit' ;
23
17
import { MatPopoverEditModule } from './index' ;
@@ -297,12 +291,6 @@ const testCases = [
297
291
] as const ;
298
292
299
293
describe ( 'Material Popover Edit' , ( ) => {
300
- beforeEach ( ( ) => {
301
- TestBed . configureTestingModule ( {
302
- providers : [ provideZoneChangeDetection ( ) ] ,
303
- } ) ;
304
- } ) ;
305
-
306
294
for ( const [ componentClass , label ] of testCases ) {
307
295
describe ( label , ( ) => {
308
296
let component : BaseTestComponent ;
@@ -317,6 +305,7 @@ describe('Material Popover Edit', () => {
317
305
component = fixture . componentInstance ;
318
306
fixture . detectChanges ( ) ;
319
307
tick ( 10 ) ;
308
+ fixture . detectChanges ( ) ;
320
309
} ) ) ;
321
310
322
311
describe ( 'row hover content' , ( ) => {
@@ -432,6 +421,7 @@ describe('Material Popover Edit', () => {
432
421
433
422
it ( 'does not trigger edit when disabled' , fakeAsync ( ( ) => {
434
423
component . nameEditDisabled = true ;
424
+ fixture . changeDetectorRef . markForCheck ( ) ;
435
425
fixture . detectChanges ( ) ;
436
426
437
427
// Uses Enter to open the lens.
@@ -452,6 +442,7 @@ describe('Material Popover Edit', () => {
452
442
453
443
it ( 'unsets tabindex to 0 on disabled cells' , ( ) => {
454
444
component . nameEditDisabled = true ;
445
+ fixture . changeDetectorRef . markForCheck ( ) ;
455
446
fixture . detectChanges ( ) ;
456
447
457
448
expect ( component . getEditCell ( ) . hasAttribute ( 'tabindex' ) ) . toBe ( false ) ;
@@ -594,6 +585,7 @@ matPopoverEditTabOut`, fakeAsync(() => {
594
585
595
586
it ( 'positions the lens at the top left corner and spans the full width of the cell' , fakeAsync ( ( ) => {
596
587
component . openLens ( ) ;
588
+ fixture . detectChanges ( ) ;
597
589
598
590
const paneRect = component . getEditPane ( ) ! . getBoundingClientRect ( ) ;
599
591
const cellRect = component . getEditCell ( ) . getBoundingClientRect ( ) ;
@@ -610,16 +602,19 @@ matPopoverEditTabOut`, fakeAsync(() => {
610
602
) ;
611
603
612
604
component . colspan = { before : 1 } ;
605
+ fixture . changeDetectorRef . markForCheck ( ) ;
613
606
fixture . detectChanges ( ) ;
614
607
615
608
component . openLens ( ) ;
609
+ fixture . detectChanges ( ) ;
616
610
617
611
let paneRect = component . getEditPane ( ) ! . getBoundingClientRect ( ) ;
618
612
expectPixelsToEqual ( paneRect . top , cellRects [ 0 ] . top ) ;
619
613
expectPixelsToEqual ( paneRect . left , cellRects [ 0 ] . left ) ;
620
614
expectPixelsToEqual ( paneRect . right , cellRects [ 1 ] . right ) ;
621
615
622
616
component . colspan = { after : 1 } ;
617
+ fixture . changeDetectorRef . markForCheck ( ) ;
623
618
fixture . detectChanges ( ) ;
624
619
625
620
paneRect = component . getEditPane ( ) ! . getBoundingClientRect ( ) ;
@@ -630,6 +625,7 @@ matPopoverEditTabOut`, fakeAsync(() => {
630
625
// expectPixelsToEqual(paneRect.right, cellRects[2].right);
631
626
632
627
component . colspan = { before : 1 , after : 1 } ;
628
+ fixture . changeDetectorRef . markForCheck ( ) ;
633
629
fixture . detectChanges ( ) ;
634
630
635
631
paneRect = component . getEditPane ( ) ! . getBoundingClientRect ( ) ;
@@ -706,13 +702,15 @@ matPopoverEditTabOut`, fakeAsync(() => {
706
702
expect ( component . lensIsOpen ( ) ) . toBe ( false ) ;
707
703
708
704
component . openLens ( ) ;
705
+ fixture . detectChanges ( ) ;
709
706
710
707
expect ( component . getInput ( ) ! . value ) . toBe ( 'Hydragon' ) ;
711
708
clearLeftoverTimers ( ) ;
712
709
} ) ) ;
713
710
714
711
it ( 'resets the lens to original value' , fakeAsync ( ( ) => {
715
712
component . openLens ( ) ;
713
+ fixture . detectChanges ( ) ;
716
714
717
715
component . getInput ( ) ! . value = 'Hydragon' ;
718
716
component . getInput ( ) ! . dispatchEvent ( new Event ( 'input' ) ) ;
@@ -733,6 +731,7 @@ matPopoverEditTabOut`, fakeAsync(() => {
733
731
fixture . detectChanges ( ) ;
734
732
735
733
component . openLens ( ) ;
734
+ fixture . detectChanges ( ) ;
736
735
737
736
component . getInput ( ) ! . value = 'Hydragon X' ;
738
737
component . getInput ( ) ! . dispatchEvent ( new Event ( 'input' ) ) ;
0 commit comments