Skip to content

Commit 3c66200

Browse files
jelbourncrisbeto
authored andcommitted
wip debugging
1 parent 4731cb4 commit 3c66200

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
@@ -1222,17 +1222,19 @@ describe('MdAutocomplete', () => {
12221222
inputReference = fixture.debugElement.query(By.css('.mat-input-flex')).nativeElement;
12231223
});
12241224

1225-
it('should use below positioning by default', () => {
1225+
it('should use below positioning by default', async(() => {
12261226
fixture.componentInstance.trigger.openPanel();
12271227
fixture.detectChanges();
12281228

1229-
const inputBottom = inputReference.getBoundingClientRect().bottom;
1230-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1231-
const panelTop = panel.getBoundingClientRect().top;
1229+
fixture.whenStable().then(() => {
1230+
const inputBottom = inputReference.getBoundingClientRect().bottom;
1231+
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1232+
const panelTop = panel.getBoundingClientRect().top;
12321233

1233-
expect(Math.floor(inputBottom))
1234-
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1235-
});
1234+
expect(Math.floor(inputBottom))
1235+
.toEqual(Math.floor(panelTop), `Expected panel top to match input bottom by default.`);
1236+
});
1237+
}));
12361238

12371239
it('should reposition the panel on scroll', () => {
12381240
const spacer = document.createElement('div');
@@ -1248,7 +1250,7 @@ describe('MdAutocomplete', () => {
12481250
fixture.detectChanges();
12491251

12501252
const inputBottom = inputReference.getBoundingClientRect().bottom;
1251-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1253+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
12521254
const panelTop = panel.getBoundingClientRect().top;
12531255

12541256
expect(Math.floor(inputBottom)).toEqual(Math.floor(panelTop),
@@ -1257,21 +1259,23 @@ describe('MdAutocomplete', () => {
12571259
document.body.removeChild(spacer);
12581260
});
12591261

1260-
it('should fall back to above position if panel cannot fit below', () => {
1262+
it('should fall back to above position if panel cannot fit below', async(() => {
12611263
// Push the autocomplete trigger down so it won't have room to open "below"
12621264
inputReference.style.top = '600px';
12631265
inputReference.style.position = 'relative';
12641266

12651267
fixture.componentInstance.trigger.openPanel();
12661268
fixture.detectChanges();
12671269

1268-
const inputTop = inputReference.getBoundingClientRect().top;
1269-
const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!;
1270-
const panelBottom = panel.getBoundingClientRect().bottom;
1270+
fixture.whenStable().then(() => {
1271+
const inputTop = inputReference.getBoundingClientRect().top;
1272+
const panel = overlayContainerElement.querySelector('.cdk-overlay-pane')!;
1273+
const panelBottom = panel.getBoundingClientRect().bottom;
12711274

1272-
expect(Math.floor(inputTop))
1273-
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1274-
});
1275+
expect(Math.floor(inputTop))
1276+
.toEqual(Math.floor(panelBottom), `Expected panel to fall back to above position.`);
1277+
});
1278+
}));
12751279

12761280
it('should align panel properly when filtering in "above" position', async(() => {
12771281
// 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
@@ -42,7 +42,7 @@ import {
4242
import {extendObject} from '../core/util/object-extend';
4343

4444

45-
describe('MdSelect', () => {
45+
fdescribe('MdSelect', () => {
4646
let overlayContainerElement: HTMLElement;
4747
let dir: {value: 'ltr'|'rtl'};
4848
let scrolledSubject = new Subject();
@@ -104,9 +104,7 @@ describe('MdSelect', () => {
104104
}};
105105
}}
106106
]
107-
});
108-
109-
TestBed.compileComponents();
107+
}).compileComponents();
110108
}));
111109

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

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

0 commit comments

Comments
 (0)