UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

111 lines (91 loc) 3.84 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ <span id='Siesta-Test-Action-Type'>/** </span> @class Siesta.Test.Action.Type @extends Siesta.Test.Action @mixin Siesta.Test.Action.Role.HasTarget This action will {@link Siesta.Test.Browser#type type} the provided {@link #text} into the provided {@link #target}. For more information about how you can type special characters and hold special keys such as ALT or SHIFT, please see the docs for the {@link Siesta.Test.Browser#type type} method. The target provide should be a {@link Siesta.Test.ActionTarget} - CSS selector, DOM element instance, Component Query etc. This action can be included in a `t.chain` call with the &quot;type&quot; shortcut. **Note** that unlike other actions, in its compact form the value of the &quot;type&quot; property should contain the text to type, not the target of action. t.chain( { // &quot;type&quot; into the currently focused DOM element type : &#39;Some text[ENTER]&#39; }, // or { action : &#39;type&#39;, target : someDOMElement, text : &#39;Some text&#39;, options : { shiftKey : true } }, // or { // NOTE: &quot;type&quot; contains text to type, not the action target as in other actions type : &#39;Some text&#39;, target : someDOMElement } ); */ Class(&#39;Siesta.Test.Action.Type&#39;, { isa : Siesta.Test.Action, does : Siesta.Test.Action.Role.HasTarget, has : { requiredTestMethod : &#39;type&#39;, <span id='Siesta-Test-Action-Type-cfg-text'> /** </span> * @cfg {String} text * * The text to type into the target */ text : &#39;&#39;, <span id='Siesta-Test-Action-Type-cfg-options'> /** </span> * @cfg {Object} options * * Any options that will be used when simulating the event. For information about possible * config options, please see: &lt;https://developer.mozilla.org/en-US/docs/DOM/event.initMouseEvent&gt; */ options : null, <span id='Siesta-Test-Action-Type-cfg-clearExisting'> /** </span> * @cfg {Boolean} clearExisting * * true to clear existing text in the target before typing */ clearExisting : false }, methods : { process : function () { var waitForTarget = this.waitForTarget || !!this.target; // By default use the current focused element as target this.target = this.target || this.test.activeElement(); // additional &quot;getTarget&quot; to allow functions as &quot;target&quot; value this.test.type(this.getTarget(), this.text, this.next, null, this.options, this.clearExisting, waitForTarget); } } }); Siesta.Test.ActionRegistry().registerAction(&#39;type&#39;, Siesta.Test.Action.Type)</pre> </body> </html>