Skip to content

Commit 6348841

Browse files
committed
ignore rounding error in IE
1 parent c8fadfd commit 6348841

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/lib/select/select.spec.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Directionality} from '@angular/cdk/bidi';
22
import {DOWN_ARROW, END, ENTER, HOME, SPACE, TAB, UP_ARROW} from '@angular/cdk/keycodes';
33
import {OverlayContainer} from '@angular/cdk/overlay';
4+
import {Platform} from '@angular/cdk/platform';
45
import {ScrollDispatcher, ViewportRuler} from '@angular/cdk/scrolling';
56
import {dispatchFakeEvent, dispatchKeyboardEvent, wrappedErrorMessage} from '@angular/cdk/testing';
67
import {
@@ -1721,8 +1722,18 @@ describe('MdSelect', () => {
17211722
const option = overlayContainerElement.querySelector('.cdk-overlay-pane md-option');
17221723
const optionTop = option ? option.getBoundingClientRect().top : 0;
17231724

1724-
expect(optionTop + (menuItemHeight - triggerHeight) / 2)
1725-
.toBe(triggerTop, 'Expected trigger to align with the first option.');
1725+
// There appears to be a small rounding error on IE, so we verify that the value is close,
1726+
// not exact.
1727+
let platform = new Platform();
1728+
if (platform.TRIDENT) {
1729+
let difference =
1730+
Math.abs(optionTop + (menuItemHeight - triggerHeight) / 2 - triggerTop);
1731+
expect(difference)
1732+
.toBeLessThan(0.1, 'Expected trigger to align with the first option.');
1733+
} else {
1734+
expect(optionTop + (menuItemHeight - triggerHeight) / 2)
1735+
.toBe(triggerTop, 'Expected trigger to align with the first option.');
1736+
}
17261737
});
17271738
}));
17281739
});

src/lib/select/select.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
ScrollStrategy,
1919
ViewportRuler,
2020
} from '@angular/cdk/overlay';
21-
import {Platform} from '@angular/cdk/platform';
2221
import {filter, first, startWith} from '@angular/cdk/rxjs';
2322
import {
2423
AfterContentInit,

0 commit comments

Comments
 (0)