Skip to content

Commit

Permalink
chore: try to fix edge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jun 13, 2017
1 parent bcabda9 commit b049c8e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../core/placeholder/placeholder-options';


describe('MdSelect', () => {
fdescribe('MdSelect', () => {
let overlayContainerElement: HTMLElement;
let dir: {value: 'ltr'|'rtl'};
let scrolledSubject = new Subject();
Expand Down Expand Up @@ -1319,15 +1319,23 @@ describe('MdSelect', () => {
describe('x-axis positioning', () => {

beforeEach(() => {
<<<<<<< HEAD
select.style.position = 'fixed';
select.style.left = '30px';
});

it('should align the trigger and the selected option on the x-axis in ltr', fakeAsync(() => {
=======
select.style.marginLeft = select.style.marginRight = '50px';
});

it('should align the trigger and the selected option on the x-axis in ltr', async(() => {
>>>>>>> chore: try to fix edge tests
trigger.click();
tick(400);
fixture.detectChanges();

<<<<<<< HEAD
const triggerLeft = trigger.getBoundingClientRect().left;
const firstOptionLeft = document.querySelector('.cdk-overlay-pane md-option')
.getBoundingClientRect().left;
Expand All @@ -1339,13 +1347,30 @@ describe('MdSelect', () => {
}));

it('should align the trigger and the selected option on the x-axis in rtl', fakeAsync(() => {
=======
fixture.whenStable().then(() => {
const triggerLeft = trigger.getBoundingClientRect().left;
const firstOptionLeft =
document.querySelector('.cdk-overlay-pane md-option').getBoundingClientRect().left;

// Each option is 32px wider than the trigger, so it must be adjusted 16px
// to ensure the text overlaps correctly.
expect(firstOptionLeft.toFixed(2))
.toEqual((triggerLeft - 16).toFixed(2),
`Expected trigger to align with the selected option on the x-axis in LTR.`);
});
}));

it('should align the trigger and the selected option on the x-axis in rtl', async(() => {
>>>>>>> chore: try to fix edge tests
dir.value = 'rtl';
fixture.detectChanges();

trigger.click();
tick(400);
fixture.detectChanges();

<<<<<<< HEAD
const triggerRight = trigger.getBoundingClientRect().right;
const firstOptionRight =
document.querySelector('.cdk-overlay-pane md-option').getBoundingClientRect().right;
Expand Down Expand Up @@ -1468,6 +1493,21 @@ describe('MdSelect', () => {
expect(Math.floor(selectedOptionLeft)).toEqual(Math.floor(triggerLeft - 16));
}));

=======
fixture.whenStable().then(() => {
const triggerRight = trigger.getBoundingClientRect().right;
const firstOptionRight =
document.querySelector('.cdk-overlay-pane md-option').getBoundingClientRect().right;

// Each option is 32px wider than the trigger, so it must be adjusted 16px
// to ensure the text overlaps correctly.
expect(firstOptionRight.toFixed(2))
.toEqual((triggerRight + 16).toFixed(2),
`Expected trigger to align with the selected option on the x-axis in RTL.`);
});
}));

>>>>>>> chore: try to fix edge tests
});

describe('with header', () => {
Expand Down

0 comments on commit b049c8e

Please sign in to comment.