Skip to content

Commit b905130

Browse files
committed
chore(): fix travis tests (#2925)
1 parent eec4dc6 commit b905130

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/demo-app/autocomplete/autocomplete-demo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Component, ViewEncapsulation} from '@angular/core';
22
import {FormControl} from '@angular/forms';
3-
import {Observable} from 'rxjs/Observable';
43
import 'rxjs/add/operator/startWith';
54

65
@Component({
@@ -15,7 +14,7 @@ export class AutocompleteDemo {
1514
currentState = '';
1615
topHeightCtrl = new FormControl(0);
1716

18-
reactiveStates: Observable<any>;
17+
reactiveStates: any;
1918
tdStates: any[];
2019

2120
tdDisabled = false;

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,23 @@ describe('MdAutocomplete', () => {
182182
});
183183
}));
184184

185-
it('should keep the label floating until the panel closes', () => {
185+
it('should keep the label floating until the panel closes', async(() => {
186186
fixture.componentInstance.trigger.openPanel();
187-
fixture.detectChanges();
188-
189-
dispatchEvent('blur', input);
190-
fixture.detectChanges();
191-
192187
expect(fixture.componentInstance.inputContainer.floatPlaceholder)
193-
.toEqual('always', 'Expected placeholder to keep floating on blur.');
188+
.toEqual('always', 'Expected placeholder to float as soon as panel opens.');
194189

195-
const backdrop =
196-
overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement;
197-
backdrop.click();
198-
fixture.detectChanges();
190+
fixture.whenStable().then(() => {
191+
fixture.detectChanges();
199192

200-
expect(fixture.componentInstance.inputContainer.floatPlaceholder)
201-
.toEqual('auto', 'Expected placeholder to return to auto state after panel closes.');
202-
});
193+
const options =
194+
overlayContainerElement.querySelectorAll('md-option') as NodeListOf<HTMLElement>;
195+
options[1].click();
196+
fixture.detectChanges();
197+
198+
expect(fixture.componentInstance.inputContainer.floatPlaceholder)
199+
.toEqual('auto', 'Expected placeholder to return to auto state after panel closes.');
200+
});
201+
}));
203202

204203
});
205204

@@ -739,8 +738,8 @@ describe('MdAutocomplete', () => {
739738
const panelTop = panel.getBoundingClientRect().top;
740739

741740
// Panel is offset by 6px in styles so that the underline has room to display.
742-
expect((inputBottom + 6).toFixed(2))
743-
.toEqual(panelTop.toFixed(2), `Expected panel top to match input bottom by default.`);
741+
expect((inputBottom + 6).toFixed(1))
742+
.toEqual(panelTop.toFixed(1), `Expected panel top to match input bottom by default.`);
744743
expect(fixture.componentInstance.trigger.autocomplete.positionY)
745744
.toEqual('below', `Expected autocomplete positionY to default to below.`);
746745
});
@@ -758,8 +757,8 @@ describe('MdAutocomplete', () => {
758757
const panelBottom = panel.getBoundingClientRect().bottom;
759758

760759
// Panel is offset by 24px in styles so that the label has room to display.
761-
expect((inputTop - 24).toFixed(2))
762-
.toEqual(panelBottom.toFixed(2), `Expected panel to fall back to above position.`);
760+
expect((inputTop - 24).toFixed(1))
761+
.toEqual(panelBottom.toFixed(1), `Expected panel to fall back to above position.`);
763762
expect(fixture.componentInstance.trigger.autocomplete.positionY)
764763
.toEqual('above', `Expected autocomplete positionY to be "above" if panel won't fit.`);
765764
});
@@ -782,8 +781,8 @@ describe('MdAutocomplete', () => {
782781
const panelBottom = panel.getBoundingClientRect().bottom;
783782

784783
// Panel is offset by 24px in styles so that the label has room to display.
785-
expect((inputTop - 24).toFixed(2))
786-
.toEqual(panelBottom.toFixed(2), `Expected panel to stay aligned after filtering.`);
784+
expect((inputTop - 24).toFixed(1))
785+
.toEqual(panelBottom.toFixed(1), `Expected panel to stay aligned after filtering.`);
787786
expect(fixture.componentInstance.trigger.autocomplete.positionY)
788787
.toEqual('above', `Expected autocomplete positionY to be "above" if panel won't fit.`);
789788
});

src/lib/autocomplete/autocomplete.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import {
99
ViewEncapsulation
1010
} from '@angular/core';
1111
import {MdOption} from '../core';
12-
import {MenuPositionY} from '../menu/menu-positions';
1312

1413
/**
1514
* Autocomplete IDs need to be unique across components, so this counter exists outside of
1615
* the component definition.
1716
*/
1817
let _uniqueAutocompleteIdCounter = 0;
1918

19+
export type AutocompletePositionY = 'above' | 'below';
20+
2021
@Component({
2122
moduleId: module.id,
2223
selector: 'md-autocomplete, mat-autocomplete',
@@ -28,7 +29,7 @@ let _uniqueAutocompleteIdCounter = 0;
2829
export class MdAutocomplete {
2930

3031
/** Whether the autocomplete panel displays above or below its trigger. */
31-
positionY: MenuPositionY = 'below';
32+
positionY: AutocompletePositionY = 'below';
3233

3334
@ViewChild(TemplateRef) template: TemplateRef<any>;
3435
@ViewChild('panel') panel: ElementRef;

0 commit comments

Comments
 (0)