siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
111 lines (91 loc) • 3.84 kB
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 "type" shortcut. **Note** that unlike other actions, in its compact
form the value of the "type" property should contain the text to type, not the target of action.
t.chain(
{
// "type" into the currently focused DOM element
type : 'Some text[ENTER]'
},
// or
{
action : 'type',
target : someDOMElement,
text : 'Some text',
options : { shiftKey : true }
},
// or
{
// NOTE: "type" contains text to type, not the action target as in other actions
type : 'Some text',
target : someDOMElement
}
);
*/
Class('Siesta.Test.Action.Type', {
isa : Siesta.Test.Action,
does : Siesta.Test.Action.Role.HasTarget,
has : {
requiredTestMethod : 'type',
<span id='Siesta-Test-Action-Type-cfg-text'> /**
</span> * @cfg {String} text
*
* The text to type into the target
*/
text : '',
<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: <https://developer.mozilla.org/en-US/docs/DOM/event.initMouseEvent>
*/
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 "getTarget" to allow functions as "target" value
this.test.type(this.getTarget(), this.text, this.next, null, this.options, this.clearExisting, waitForTarget);
}
}
});
Siesta.Test.ActionRegistry().registerAction('type', Siesta.Test.Action.Type)</pre>
</body>
</html>