Skip to content

Commit c873c85

Browse files
committed
fix(select-spec): Update the rtl test to ensure the fixture is stable
1 parent 1a67107 commit c873c85

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/lib/select/select.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -991,22 +991,24 @@ describe('MdSelect', () => {
991991
`Expected trigger to align with the selected option on the x-axis in LTR.`);
992992
});
993993

994-
it('should align the trigger and the selected option on the x-axis in rtl', () => {
994+
it('should align the trigger and the selected option on the x-axis in rtl', async(() => {
995995
dir.value = 'rtl';
996996

997997
trigger.click();
998998
fixture.detectChanges();
999999

1000-
const triggerRight = trigger.getBoundingClientRect().right;
1001-
const firstOptionRight =
1002-
document.querySelector('.cdk-overlay-pane md-option').getBoundingClientRect().right;
1003-
1004-
// Each option is 32px wider than the trigger, so it must be adjusted 16px
1005-
// to ensure the text overlaps correctly.
1006-
expect(firstOptionRight.toFixed(2))
1007-
.toEqual((triggerRight + 16).toFixed(2),
1008-
`Expected trigger to align with the selected option on the x-axis in RTL.`);
1009-
});
1000+
fixture.whenStable().then(() => {
1001+
const triggerRight = trigger.getBoundingClientRect().right;
1002+
const firstOptionRight =
1003+
document.querySelector('.cdk-overlay-pane md-option').getBoundingClientRect().right;
1004+
1005+
// Each option is 32px wider than the trigger, so it must be adjusted 16px
1006+
// to ensure the text overlaps correctly.
1007+
expect(firstOptionRight.toFixed(2))
1008+
.toEqual((triggerRight + 16).toFixed(2),
1009+
`Expected trigger to align with the selected option on the x-axis in RTL.`);
1010+
});
1011+
}));
10101012
});
10111013

10121014
});

0 commit comments

Comments
 (0)