Skip to content

Commit b693766

Browse files
committed
fix: unit test failures
1 parent 47ecc3d commit b693766

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('MdAutocomplete', () => {
9191
.toContain('California', `Expected panel to display when opened programmatically.`);
9292
});
9393

94-
it('should close the panel when blurred', async(() => {
94+
it('should close the panel when input loses focus', async(() => {
9595
dispatchFakeEvent(input, 'focus');
9696
fixture.detectChanges();
9797

@@ -463,7 +463,7 @@ describe('MdAutocomplete', () => {
463463
.toBe(false, `Expected control to stay pristine if value is set programmatically.`);
464464
});
465465

466-
it('should mark the autocomplete control as touched on blur', () => {
466+
it('should mark the autocomplete control as touched on focusout', () => {
467467
fixture.componentInstance.trigger.openPanel();
468468
fixture.detectChanges();
469469
expect(fixture.componentInstance.stateCtrl.touched)
@@ -473,7 +473,7 @@ describe('MdAutocomplete', () => {
473473
fixture.detectChanges();
474474

475475
expect(fixture.componentInstance.stateCtrl.touched)
476-
.toBe(true, `Expected control to become touched on blur.`);
476+
.toBe(true, `Expected control to become touched on focusout.`);
477477
});
478478

479479
});
@@ -998,6 +998,30 @@ class AutocompleteWithoutForms {
998998
}
999999

10001000
/**
1001+
<<<<<<< HEAD
1002+
=======
1003+
* TODO: Move this to core testing utility until Angular has event faking
1004+
* support.
1005+
*
1006+
* Dispatches an event from an element.
1007+
* @param eventName Name of the event
1008+
* @param element The element from which the event will be dispatched.
1009+
* @param extras Extra properties to be attached to the event object.
1010+
*/
1011+
function dispatchEvent(eventName: string, element: HTMLElement, extras?: any): void {
1012+
let event = document.createEvent('Event');
1013+
1014+
if (extras) {
1015+
Object.assign(event, extras);
1016+
}
1017+
1018+
event.initEvent(eventName, true, true);
1019+
element.dispatchEvent(event);
1020+
}
1021+
1022+
1023+
/**
1024+
>>>>>>> fix: unit test failures
10011025
* Focuses an input, sets its value and dispatches
10021026
* the `input` event, simulating the user typing.
10031027
* @param value Value to be set on the input.

0 commit comments

Comments
 (0)