UNPKG

siesta-lite

Version:

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

113 lines (94 loc) 3.75 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-MethodCall'>/** </span> @class Siesta.Test.Action.MethodCall @extends Siesta.Test.Action This action allows you to call any method of the test class. You can add it to the `chain` method by providing a property in the config object, which corresponds to some method of the test class. The value of this property should contain arguments for the method call (see {@link #args}). t.chain( function (next) { t.someMethodCall(&#39;arg1&#39;, &#39;arg2&#39;, next) }, // or { someMethodCall : [ &#39;arg1&#39;, &#39;arg2&#39; ] }, ... { waitForSelector : &#39;.selector&#39; } ) */ Class(&#39;Siesta.Test.Action.MethodCall&#39;, { isa : Siesta.Test.Action, has : { <span id='Siesta-Test-Action-MethodCall-cfg-methodName'> /** </span> * @cfg {String} methodName * * A name of the method to call. */ methodName : null, <span id='Siesta-Test-Action-MethodCall-cfg-args'> /** </span> * @cfg {Array/Function/Object} args * * Arguments for the method call. Usually should be an array. * * If its a function, then the function will be called at the action execution time and result from the * action will be treated as `args`. The only exception is the &quot;waitForFn&quot; method, for which the supplied function * will be treated as the 1st argument for the &quot;waitForFn&quot; method. * * Anything else will be converted to a single element array. * * The callback will be added as the last argument (after resolving this config), unless the {@link #callbackIndex} is specified. */ args : null, <span id='Siesta-Test-Action-MethodCall-cfg-callbackIndex'> /** </span> * @cfg {Number} callbackIndex An index in the {@link #args} array where the callback should be inserted. */ callbackIndex : null }, methods : { process : function () { var test = this.test var methodName = this.methodName var args = this.args if (test.typeOf(args) == &#39;Function&#39;) args = args.call(test, this) if (test.typeOf(args) == &#39;Array&#39;) { args = args.slice(); } else { args = [ args ] } if (this.callbackIndex != null) args.splice(this.callbackIndex, 0, this.next) else args.push(this.next) test[ methodName ].apply(test, args) } } }); Siesta.Test.ActionRegistry().registerAction(&#39;methodCall&#39;, Siesta.Test.Action.MethodCall) </pre> </body> </html>