Skip to content

Commit f4c23b9

Browse files
test(dialog): add tests for minWidth, minHeight, maxWidth and maxHeight
1 parent 43d66d6 commit f4c23b9

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/lib/dialog/dialog.spec.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,69 @@ describe('MatDialog', () => {
336336
expect(overlayPane.style.height).toBe('100px');
337337
});
338338

339+
it('should should override the min-width of the overlay pane', () => {
340+
dialog.open(PizzaMsg, {
341+
minWidth: '500px'
342+
});
343+
344+
viewContainerFixture.detectChanges();
345+
346+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
347+
348+
expect(overlayPane.style.minWidth).toBe('500px');
349+
});
350+
351+
it('should should override the max-width of the overlay pane', fakeAsync(() => {
352+
let dialogRef = dialog.open(PizzaMsg);
353+
354+
viewContainerFixture.detectChanges();
355+
356+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
357+
358+
expect(overlayPane.style.maxWidth).toBe('80vw',
359+
'Expected dialog to set a default max-width on overlay pane');
360+
361+
dialogRef.close();
362+
363+
tick(500);
364+
viewContainerFixture.detectChanges();
365+
flushMicrotasks();
366+
367+
dialogRef = dialog.open(PizzaMsg, {
368+
maxWidth: '100px'
369+
});
370+
371+
viewContainerFixture.detectChanges();
372+
373+
overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
374+
375+
expect(overlayPane.style.maxWidth).toBe('100px');
376+
}));
377+
378+
it('should should override the min-height of the overlay pane', () => {
379+
dialog.open(PizzaMsg, {
380+
minHeight: '300px'
381+
});
382+
383+
viewContainerFixture.detectChanges();
384+
385+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
386+
387+
expect(overlayPane.style.minHeight).toBe('300px');
388+
});
389+
390+
it('should should override the max-height of the overlay pane', () => {
391+
dialog.open(PizzaMsg, {
392+
maxHeight: '100px'
393+
});
394+
395+
viewContainerFixture.detectChanges();
396+
397+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
398+
399+
expect(overlayPane.style.maxHeight).toBe('100px');
400+
});
401+
339402
it('should should override the top offset of the overlay pane', () => {
340403
dialog.open(PizzaMsg, {
341404
position: {

0 commit comments

Comments
 (0)