Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kara committed Mar 10, 2017
1 parent 514003e commit 0c3c2bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {MdAutocomplete} from './autocomplete';
import {MdInputContainer} from '../input/input-container';
import {Observable} from 'rxjs/Observable';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {typeInElement} from '../core/testing/type-in-element';

import 'rxjs/add/operator/map';

Expand Down Expand Up @@ -781,7 +782,7 @@ describe('MdAutocomplete', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(input.getAttribute('aria-expanded'))
.toBe('false', 'Expected aria-expanded to be false when panel hides itself.');
.toBe('false', 'Expected aria-expanded to be false when panel hides itself.');
});
});
});
Expand Down Expand Up @@ -1025,18 +1026,6 @@ class AutocompleteWithoutForms {

}

/**
* Focuses an input, sets its value and dispatches
* the `input` event, simulating the user typing.
* @param value Value to be set on the input.
* @param element Element onto which to set the value.
*/
function typeInElement(value: string, element: HTMLInputElement, autoFocus = true) {
element.focus();
element.value = value;
dispatchFakeEvent(element, 'input');
}

/** This is a mock keyboard event to test keyboard events in the autocomplete. */
class MockKeyboardEvent {
constructor(public keyCode: number) {}
Expand Down
13 changes: 13 additions & 0 deletions src/lib/core/testing/type-in-element.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {dispatchFakeEvent} from './dispatch-events';

/**
* Focuses an input, sets its value and dispatches
* the `input` event, simulating the user typing.
* @param value Value to be set on the input.
* @param element Element onto which to set the value.
*/
export function typeInElement(value: string, element: HTMLInputElement, autoFocus = true) {
element.focus();
element.value = value;
dispatchFakeEvent(element, 'input');
}

0 comments on commit 0c3c2bb

Please sign in to comment.