Skip to content

Commit 075f337

Browse files
committed
wip debugging
1 parent 2a17afa commit 075f337

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,17 +1135,19 @@ describe('MdAutocomplete', () => {
11351135
inputReference = fixture.debugElement.query(By.css('.mat-input-flex')).nativeElement;
11361136
});
11371137

1138-
it('should use below positioning by default', () => {
1138+
it('should use below positioning by default', async(() => {
11391139
fixture.componentInstance.trigger.openPanel();
11401140
fixture.detectChanges();
11411141

1142-
const inputBottom = inputReference.getBoundingClientRect().bottom;
1143-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1144-
const panelTop = panel.getBoundingClientRect().top;
1142+
fixture.whenStable().then(() => {
1143+
const inputBottom = inputReference.getBoundingClientRect().bottom;
1144+
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1145+
const panelTop = panel.getBoundingClientRect().top;
11451146

1146-
expect(Math.floor(inputBottom))
1147-
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1148-
});
1147+
expect(Math.floor(inputBottom))
1148+
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1149+
});
1150+
}));
11491151

11501152
it('should reposition the panel on scroll', () => {
11511153
const spacer = document.createElement('div');
@@ -1161,7 +1163,7 @@ describe('MdAutocomplete', () => {
11611163
fixture.detectChanges();
11621164

11631165
const inputBottom = inputReference.getBoundingClientRect().bottom;
1164-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1166+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
11651167
const panelTop = panel.getBoundingClientRect().top;
11661168

11671169
expect(Math.floor(inputBottom)).toEqual(Math.floor(panelTop),
@@ -1170,21 +1172,23 @@ describe('MdAutocomplete', () => {
11701172
document.body.removeChild(spacer);
11711173
});
11721174

1173-
it('should fall back to above position if panel cannot fit below', () => {
1175+
it('should fall back to above position if panel cannot fit below', async(() => {
11741176
// Push the autocomplete trigger down so it won't have room to open "below"
11751177
inputReference.style.top = '600px';
11761178
inputReference.style.position = 'relative';
11771179

11781180
fixture.componentInstance.trigger.openPanel();
11791181
fixture.detectChanges();
11801182

1181-
const inputTop = inputReference.getBoundingClientRect().top;
1182-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1183-
const panelBottom = panel.getBoundingClientRect().bottom;
1183+
fixture.whenStable().then(() => {
1184+
const inputTop = inputReference.getBoundingClientRect().top;
1185+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
1186+
const panelBottom = panel.getBoundingClientRect().bottom;
11841187

1185-
expect(Math.floor(inputTop))
1186-
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1187-
});
1188+
expect(Math.floor(inputTop))
1189+
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1190+
});
1191+
}));
11881192

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

src/lib/menu/menu.spec.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from '@angular/cdk/testing';
3333

3434

35-
fdescribe('MdMenu', () => {
35+
describe('MdMenu', () => {
3636
let overlayContainerElement: HTMLElement;
3737
let dir: Direction;
3838

@@ -364,8 +364,8 @@ fdescribe('MdMenu', () => {
364364
* subject.openMenu();
365365
*/
366366
class OverlapSubject<T extends TestableMenu> {
367-
private readonly fixture: ComponentFixture<T>;
368-
private readonly trigger: any;
367+
readonly fixture: ComponentFixture<T>;
368+
readonly trigger: any;
369369

370370
constructor(ctor: {new(): T; }, inputs: {[key: string]: any} = {}) {
371371
this.fixture = TestBed.createComponent(ctor);
@@ -383,6 +383,7 @@ fdescribe('MdMenu', () => {
383383
return extendObject(this.trigger.style, style);
384384
}
385385

386+
386387
get overlayRect() {
387388
return this.overlayPane.getBoundingClientRect();
388389
}
@@ -444,11 +445,11 @@ fdescribe('MdMenu', () => {
444445

445446
it('repositions the origin to be below, so the menu opens from the trigger', () => {
446447
subject.openMenu();
448+
subject.fixture.detectChanges();
447449

448450
expect(subject.menuPanel!.classList).toContain('mat-menu-below');
449451
expect(subject.menuPanel!.classList).not.toContain('mat-menu-above');
450452
});
451-
452453
});
453454
});
454455

@@ -805,7 +806,7 @@ fdescribe('MdMenu', () => {
805806
fixture.detectChanges();
806807

807808
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
808-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
809+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
809810

810811
expect(Math.round(triggerRect.right)).toBe(Math.round(panelRect.left));
811812
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
@@ -823,7 +824,7 @@ fdescribe('MdMenu', () => {
823824
fixture.detectChanges();
824825

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

828829
expect(Math.round(triggerRect.left)).toBe(Math.round(panelRect.right));
829830
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
@@ -842,32 +843,28 @@ fdescribe('MdMenu', () => {
842843
fixture.detectChanges();
843844

844845
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
845-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
846+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
846847

847848
expect(Math.round(triggerRect.left)).toBe(Math.round(panelRect.right));
848849
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);
849850
});
850851

851-
fit('should fall back to aligning to the right edge of the trigger in rtl', fakeAsync(() => {
852+
it('should fall back to aligning to the right edge of the trigger in rtl', fakeAsync(() => {
852853
dir = 'rtl';
853854
compileTestComponent();
854855
instance.rootTriggerEl.nativeElement.style.position = 'fixed';
855856
instance.rootTriggerEl.nativeElement.style.left = '10px';
856857
instance.rootTriggerEl.nativeElement.style.top = '50%';
857858
instance.rootTrigger.openMenu();
858859
fixture.detectChanges();
859-
tick(1000);
860+
tick(500);
860861

861862
instance.levelOneTrigger.openMenu();
862863
fixture.detectChanges();
863-
tick(1000);
864-
865-
866-
fixture.detectChanges();
867-
tick(1000);
864+
tick(500);
868865

869866
const triggerRect = overlay.querySelector('#level-one-trigger')!.getBoundingClientRect();
870-
const panelRect = overlay.querySelectorAll('.mat-menu-panel')[1].getBoundingClientRect();
867+
const panelRect = overlay.querySelectorAll('.cdk-overlay-pane')[1].getBoundingClientRect();
871868

872869
expect(Math.round(triggerRect.right)).toBe(Math.round(panelRect.left));
873870
expect(Math.round(triggerRect.top)).toBe(Math.round(panelRect.top) + MENU_PANEL_TOP_PADDING);

src/lib/select/select.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
import {extendObject} from '../core/util/object-extend';
4242

4343

44-
describe('MdSelect', () => {
44+
fdescribe('MdSelect', () => {
4545
let overlayContainerElement: HTMLElement;
4646
let dir: {value: 'ltr'|'rtl'};
4747
let scrolledSubject = new Subject();
@@ -103,9 +103,7 @@ describe('MdSelect', () => {
103103
}};
104104
}}
105105
]
106-
});
107-
108-
TestBed.compileComponents();
106+
}).compileComponents();
109107
}));
110108

111109
beforeEach(inject([ViewportRuler], (_ruler: ViewportRuler) => {
@@ -1631,7 +1629,7 @@ describe('MdSelect', () => {
16311629
`Expected trigger label to align along x-axis, accounting for the padding in rtl.`);
16321630
}));
16331631

1634-
it('should not adjust if all options are within a group, except the selected one',
1632+
fit('should not adjust if all options are within a group, except the selected one',
16351633
fakeAsync(() => {
16361634
groupFixture.componentInstance.control.setValue('mime-11');
16371635
groupFixture.detectChanges();

0 commit comments

Comments
 (0)