2015-12-18 11:36:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-12-25 20:15:24 +03:00
|
|
|
import { By } from '@angular/platform-browser';
|
2015-12-18 11:36:01 +03:00
|
|
|
|
|
|
|
/** Gets a child DebugElement by tag name. */
|
|
|
|
export function getChildDebugElement(parent, tagName) {
|
2016-02-11 14:38:44 +03:00
|
|
|
return parent.query(By.css(tagName));
|
2015-12-18 11:36:01 +03:00
|
|
|
}
|
2015-12-19 15:16:29 +03:00
|
|
|
|
2016-01-21 01:09:42 +03:00
|
|
|
/** Gets a child DebugElement by Component Type. */
|
|
|
|
export function getChildDebugElementByType(parent, type) {
|
2016-02-11 14:38:44 +03:00
|
|
|
return parent.query(By.directive(type));
|
2016-01-21 01:09:42 +03:00
|
|
|
}
|
|
|
|
|
2015-12-19 16:31:09 +03:00
|
|
|
/** Gets a child DebugElements by tag name. */
|
|
|
|
export function getChildDebugElementAll(parent, tagName) {
|
2016-02-11 14:38:44 +03:00
|
|
|
return parent.queryAll(By.css(tagName));
|
2015-12-19 16:31:09 +03:00
|
|
|
}
|
|
|
|
|
2015-12-19 15:16:29 +03:00
|
|
|
export function mouseclick( element ) {
|
|
|
|
// create a mouse click event
|
2017-03-15 18:51:46 +03:00
|
|
|
var dispatchedEvent
|
|
|
|
try {
|
2017-07-18 18:01:19 +03:00
|
|
|
dispatchedEvent = new MouseEvent('click', {
|
|
|
|
bubbles: true,
|
|
|
|
cancelable: false
|
|
|
|
});
|
2017-03-15 18:51:46 +03:00
|
|
|
} catch (e) {
|
|
|
|
dispatchedEvent = document.createEvent('MouseEvent');
|
|
|
|
dispatchedEvent.initEvent('click', true, false);
|
|
|
|
}
|
2015-12-19 15:16:29 +03:00
|
|
|
// send click to element
|
2017-03-15 18:51:46 +03:00
|
|
|
element.dispatchEvent(dispatchedEvent);
|
2015-12-19 15:16:29 +03:00
|
|
|
}
|