select.spec.ts (material2-7.3.3) | : | select.spec.ts (material2-7.3.4) | ||
---|---|---|---|---|
skipping to change at line 1006 | skipping to change at line 1006 | |||
it('should set the width of the overlay based on the trigger', fakeAsync(( ) => { | it('should set the width of the overlay based on the trigger', fakeAsync(( ) => { | |||
trigger.style.width = '200px'; | trigger.style.width = '200px'; | |||
trigger.click(); | trigger.click(); | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
flush(); | flush(); | |||
const pane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement; | const pane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement; | |||
expect(pane.style.minWidth).toBe('200px'); | expect(pane.style.minWidth).toBe('200px'); | |||
const scrollContainer = document.querySelector('.cdk-overlay-pane .mat-s | ||||
elect-panel'); | ||||
const scrollContainerWidth = scrollContainer!.getBoundingClientRect().wi | ||||
dth; | ||||
expect(scrollContainerWidth).toBeCloseTo(200 + 32, 0, | ||||
'Expected select panel width to be 100% + 32px of the select field t | ||||
rigger'); | ||||
})); | ||||
it('should set the width of the overlay based on a larger trigger width', | ||||
fakeAsync(() => { | ||||
// the trigger width exceeds the minimum width of the mat-select-pan | ||||
el | ||||
trigger.style.width = '400px'; | ||||
trigger.click(); | ||||
fixture.detectChanges(); | ||||
flush(); | ||||
const pane = overlayContainerElement.querySelector('.cdk-overlay-pane' | ||||
) as HTMLElement; | ||||
expect(pane.style.minWidth).toBe('400px'); | ||||
const scrollContainer = document.querySelector('.cdk-overlay-pane .mat | ||||
-select-panel'); | ||||
const scrollContainerWidth = scrollContainer!.getBoundingClientRect(). | ||||
width; | ||||
expect(scrollContainerWidth).toBeCloseTo(400 + 32, 0, | ||||
'Expected select panel width to be 100% + 32px of the select field | ||||
trigger'); | ||||
})); | })); | |||
it('should not attempt to open a select that does not have any options', f akeAsync(() => { | it('should not attempt to open a select that does not have any options', f akeAsync(() => { | |||
fixture.componentInstance.foods = []; | fixture.componentInstance.foods = []; | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
trigger.click(); | trigger.click(); | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
expect(fixture.componentInstance.select.panelOpen).toBe(false); | expect(fixture.componentInstance.select.panelOpen).toBe(false); | |||
skipping to change at line 3111 | skipping to change at line 3134 | |||
// The selected option should be scrolled to the center of the panel. | // The selected option should be scrolled to the center of the panel. | |||
// This will be its original offset from the scrollTop - half the panel height + half the | // This will be its original offset from the scrollTop - half the panel height + half the | |||
// option height. 10 (option index + 3 group labels before it) * 48 (opt ion height) = 480 | // option height. 10 (option index + 3 group labels before it) * 48 (opt ion height) = 480 | |||
// 480 (offset from scrollTop) - 256/2 + 48/2 = 376px | // 480 (offset from scrollTop) - 256/2 + 48/2 = 376px | |||
expect(Math.floor(scrollContainer.scrollTop)) | expect(Math.floor(scrollContainer.scrollTop)) | |||
.toBe(376, `Expected overlay panel to be scrolled to center the sele cted option.`); | .toBe(376, `Expected overlay panel to be scrolled to center the sele cted option.`); | |||
checkTriggerAlignedWithOption(7, groupFixture.componentInstance.select); | checkTriggerAlignedWithOption(7, groupFixture.componentInstance.select); | |||
})); | })); | |||
}); | }); | |||
describe('limited space to open vertically', () => { | describe('limited space to open vertically', () => { | |||
beforeEach(fakeAsync(() => { | beforeEach(fakeAsync(() => { | |||
formField.style.position = 'fixed'; | formField.style.position = 'fixed'; | |||
formField.style.left = '20px'; | formField.style.left = '20px'; | |||
})); | })); | |||
it('should adjust position of centered option if there is little space abo ve', | it('should adjust position of centered option if there is little space abo ve', | |||
fakeAsync(() => { | fakeAsync(() => { | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 32 lines changed or added |