2015-12-18 11:36:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import {BrowserDomAdapter} from 'angular2/platform/browser';
|
|
|
|
BrowserDomAdapter.makeCurrent();
|
|
|
|
|
|
|
|
/** Gets a child DebugElement by tag name. */
|
|
|
|
export function getChildDebugElement(parent, tagName) {
|
|
|
|
return parent.query(debugEl => {
|
|
|
|
return debugEl.nativeElement.tagName && debugEl.nativeElement.tagName.toLowerCase() === tagName;
|
|
|
|
});
|
|
|
|
}
|
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) {
|
|
|
|
return parent.query(debugEl => {
|
|
|
|
return debugEl.componentInstance instanceof type;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-12-19 16:31:09 +03:00
|
|
|
/** Gets a child DebugElements by tag name. */
|
|
|
|
export function getChildDebugElementAll(parent, tagName) {
|
|
|
|
return parent.queryAll(debugEl => {
|
|
|
|
return debugEl.nativeElement.tagName && debugEl.nativeElement.tagName.toLowerCase() === tagName;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-12-19 15:16:29 +03:00
|
|
|
export function mouseclick( element ) {
|
|
|
|
// create a mouse click event
|
|
|
|
var event = document.createEvent( 'MouseEvents' );
|
|
|
|
event.initMouseEvent( 'click', true, true, window, 1, 0, 0 );
|
|
|
|
|
|
|
|
// send click to element
|
|
|
|
element.dispatchEvent( event );
|
|
|
|
}
|