Angular 2 unit tests: How do I test for the context menu and double click events? -


i want work

 let fixture: = testbed.createcomponent(componentbeingtested);         fixture.detectchanges();         const contextmenuel: debugelement[] =  fixture.debugelement.queryall(by.css("td");          contextmenuel[0].nativeelement.oncontextmenu();         const doubleclickel: debugelement[] =  fixture.debugelement.queryall(by.css("li");          doubleclickel[0].nativeelement.ondblclick(); 

when template of component:

<td (contextmenu)="contextmenufunction">context menu</td> <li (dblclick)="dblclickfunction">double click</li> 

i errors contextmenuel[0].nativeelement.oncontextmenu not function , doubleclickel[0].nativeelement.ondblclick not function

the app functionality works expected. , yes, if change these events click in template , in test, works in test.

this how trigger context menu change:

 contextmenuel[0].triggereventhandler("contextmenu", new  mouseevent("contextmenu"));  fixture.detectchanges(); 

this how trigger double click change:

doubleclickel[0].triggereventhandler("dblclick", new mouseevent("dblclick")); fixture.detectchanges(); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -