Skip to content

Commit

Permalink
fix(popover-edit): fix failing test
Browse files Browse the repository at this point in the history
Tested component should always fit within the viewport.
Pane dimensions should be approximately compared.
  • Loading branch information
Goobles committed May 4, 2020
1 parent 597d352 commit 34cb475
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/material-experimental/popover-edit/popover-edit.spec.ts
Expand Up @@ -177,7 +177,7 @@ class ElementDataSource extends DataSource<PeriodicElement> {

@Component({
template: `
<div #table style="margin: 16px">
<div #table style="margin: 16px; max-width: 90vw; max-height: 90vh;">
<mat-table editable [dataSource]="dataSource">
<ng-container matColumnDef="before">
<mat-cell *matCellDef="let element">
Expand Down Expand Up @@ -551,9 +551,9 @@ matPopoverEditTabOut`, fakeAsync(() => {
const paneRect = component.getEditPane()!.getBoundingClientRect();
const cellRect = component.getEditCell().getBoundingClientRect();

expect(paneRect.width).toBe(cellRect.width);
expect(paneRect.left).toBe(cellRect.left);
expect(paneRect.top).toBe(cellRect.top);
expect(paneRect.width).toBeCloseTo(cellRect.width, 1);
expect(paneRect.left).toBeCloseTo(cellRect.left, 1);
expect(paneRect.top).toBeCloseTo(cellRect.top, 1);
clearLeftoverTimers();
}));

Expand All @@ -567,25 +567,25 @@ matPopoverEditTabOut`, fakeAsync(() => {
component.openLens();

let paneRect = component.getEditPane()!.getBoundingClientRect();
expect(paneRect.top).toBe(cellRects[0].top);
expect(paneRect.left).toBe(cellRects[0].left);
expect(paneRect.right).toBe(cellRects[1].right);
expect(paneRect.top).toBeCloseTo(cellRects[0].top, 1);
expect(paneRect.left).toBeCloseTo(cellRects[0].left, 1);
expect(paneRect.right).toBeCloseTo(cellRects[1].right, 1);

component.colspan = {after: 1};
fixture.detectChanges();

paneRect = component.getEditPane()!.getBoundingClientRect();
expect(paneRect.top).toBe(cellRects[1].top);
expect(paneRect.left).toBe(cellRects[1].left);
expect(paneRect.right).toBe(cellRects[2].right);
expect(paneRect.top).toBeCloseTo(cellRects[1].top, 1);
expect(paneRect.left).toBeCloseTo(cellRects[1].left, 1);
expect(paneRect.right).toBeCloseTo(cellRects[2].right, 1);

component.colspan = {before: 1, after: 1};
fixture.detectChanges();

paneRect = component.getEditPane()!.getBoundingClientRect();
expect(paneRect.top).toBe(cellRects[0].top);
expect(paneRect.left).toBe(cellRects[0].left);
expect(paneRect.right).toBe(cellRects[2].right);
expect(paneRect.top).toBeCloseTo(cellRects[0].top, 1);
expect(paneRect.left).toBeCloseTo(cellRects[0].left, 1);
expect(paneRect.right).toBeCloseTo(cellRects[2].right, 1);
clearLeftoverTimers();
}));

Expand Down

0 comments on commit 34cb475

Please sign in to comment.