Skip to content

Commit 355d851

Browse files
jelbourncrisbeto
authored andcommitted
wip debugging
1 parent b52e725 commit 355d851

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,17 +1266,19 @@ describe('MatAutocomplete', () => {
12661266
inputReference = fixture.debugElement.query(By.css('.mat-input-flex')).nativeElement;
12671267
});
12681268

1269-
it('should use below positioning by default', () => {
1269+
it('should use below positioning by default', async(() => {
12701270
fixture.componentInstance.trigger.openPanel();
12711271
fixture.detectChanges();
12721272

1273-
const inputBottom = inputReference.getBoundingClientRect().bottom;
1274-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1275-
const panelTop = panel.getBoundingClientRect().top;
1273+
fixture.whenStable().then(() => {
1274+
const inputBottom = inputReference.getBoundingClientRect().bottom;
1275+
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1276+
const panelTop = panel.getBoundingClientRect().top;
12761277

1277-
expect(Math.floor(inputBottom))
1278-
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1279-
});
1278+
expect(Math.floor(inputBottom))
1279+
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1280+
});
1281+
}));
12801282

12811283
it('should reposition the panel on scroll', () => {
12821284
const spacer = document.createElement('div');
@@ -1292,7 +1294,7 @@ describe('MatAutocomplete', () => {
12921294
fixture.detectChanges();
12931295

12941296
const inputBottom = inputReference.getBoundingClientRect().bottom;
1295-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1297+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
12961298
const panelTop = panel.getBoundingClientRect().top;
12971299

12981300
expect(Math.floor(inputBottom)).toEqual(Math.floor(panelTop),
@@ -1301,21 +1303,23 @@ describe('MatAutocomplete', () => {
13011303
document.body.removeChild(spacer);
13021304
});
13031305

1304-
it('should fall back to above position if panel cannot fit below', () => {
1306+
it('should fall back to above position if panel cannot fit below', async(() => {
13051307
// Push the autocomplete trigger down so it won't have room to open "below"
13061308
inputReference.style.top = '600px';
13071309
inputReference.style.position = 'relative';
13081310

13091311
fixture.componentInstance.trigger.openPanel();
13101312
fixture.detectChanges();
13111313

1312-
const inputTop = inputReference.getBoundingClientRect().top;
1313-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1314-
const panelBottom = panel.getBoundingClientRect().bottom;
1314+
fixture.whenStable().then(() => {
1315+
const inputTop = inputReference.getBoundingClientRect().top;
1316+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
1317+
const panelBottom = panel.getBoundingClientRect().bottom;
13151318

1316-
expect(Math.floor(inputTop))
1317-
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1318-
});
1319+
expect(Math.floor(inputTop))
1320+
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1321+
});
1322+
}));
13191323

13201324
it('should align panel properly when filtering in "above" position', async(() => {
13211325
// Push the autocomplete trigger down so it won't have room to open "below"

src/lib/menu/menu.spec.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ describe('MatMenu', () => {
366366
* subject.openMenu();
367367
*/
368368
class OverlapSubject<T extends TestableMenu> {
369-
private readonly fixture: ComponentFixture<T>;
370-
private readonly trigger: any;
369+
readonly fixture: ComponentFixture<T>;
370+
readonly trigger: any;
371371

372372
constructor(ctor: {new(): T; }, inputs: {[key: string]: any} = {}) {
373373
this.fixture = TestBed.createComponent(ctor);
@@ -385,6 +385,7 @@ describe('MatMenu', () => {
385385
return extendObject(this.trigger.style, style);
386386
}
387387

388+
388389
get overlayRect() {
389390
return this.overlayPane.getBoundingClientRect();
390391
}
@@ -446,11 +447,11 @@ describe('MatMenu', () => {
446447

447448
it('repositions the origin to be below, so the menu opens from the trigger', () => {
448449
subject.openMenu();
450+
subject.fixture.detectChanges();
449451

450452
expect(subject.menuPanel!.classList).toContain('mat-menu-below');
451453
expect(subject.menuPanel!.classList).not.toContain('mat-menu-above');
452454
});
453-
454455
});
455456
});
456457

@@ -821,7 +822,7 @@ describe('MatMenu', () => {
821822
fixture.detectChanges();
822823

823824
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
824-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
825+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
825826

826827
expect(Math.round(triggerRect.right)).toBe(Math.round(panelRect.left));
827828
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
@@ -839,7 +840,7 @@ describe('MatMenu', () => {
839840
fixture.detectChanges();
840841

841842
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
842-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
843+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
843844

844845
expect(Math.round(triggerRect.left)).toBe(Math.round(panelRect.right));
845846
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
@@ -858,32 +859,28 @@ describe('MatMenu', () => {
858859
fixture.detectChanges();
859860

860861
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
861-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
862+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
862863

863864
expect(Math.round(triggerRect.left)).toBe(Math.round(panelRect.right));
864865
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
865866
});
866867

867-
fit('should fall back to aligning to the right edge of the trigger in rtl', fakeAsync(() => {
868+
it('should fall back to aligning to the right edge of the trigger in rtl', fakeAsync(() => {
868869
dir = 'rtl';
869870
compileTestComponent();
870871
instance.rootTriggerEl.nativeElement.style.position = 'fixed';
871872
instance.rootTriggerEl.nativeElement.style.left = '10px';
872873
instance.rootTriggerEl.nativeElement.style.top = '50%';
873874
instance.rootTrigger.openMenu();
874875
fixture.detectChanges();
875-
tick(1000);
876+
tick(500);
876877

877878
instance.levelOneTrigger.openMenu();
878879
fixture.detectChanges();
879-
tick(1000);
880-
881-
882-
fixture.detectChanges();
883-
tick(1000);
880+
tick(500);
884881

885882
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
886-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
883+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
887884

888885
expect(Math.round(triggerRect.right)).toBe(Math.round(panelRect.left));
889886
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);

src/lib/select/select.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ describe('MatSelect', () => {
112112
}};
113113
}}
114114
]
115-
});
116-
117-
TestBed.compileComponents();
115+
}).compileComponents();
118116
}));
119117

120118
beforeEach(inject([ViewportRuler], (_ruler: ViewportRuler) => {
@@ -1717,7 +1715,7 @@ describe('MatSelect', () => {
17171715
`Expected trigger label to align along x-axis, accounting for the padding in rtl.`);
17181716
}));
17191717

1720-
it('should not adjust if all options are within a group, except the selected one',
1718+
fit('should not adjust if all options are within a group, except the selected one',
17211719
fakeAsync(() => {
17221720
groupFixture.componentInstance.control.setValue('mime-11');
17231721
groupFixture.detectChanges();

0 commit comments

Comments
 (0)