UNPKG

siesta-lite

Version:

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

124 lines (94 loc) 3.73 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 */ Ext.define(&#39;Siesta.Recorder.UI.Store.Action&#39;, { extend : &#39;Ext.data.TreeStore&#39;, alias : &#39;store.actionstore&#39;, model : &#39;Siesta.Recorder.UI.Model.Action&#39;, proxy : &#39;memory&#39;, root : { expanded : true }, tabSize : 4, generateCode : function (name) { var root = this.getRootNode(); var code = &#39;&#39;; var isPageNav = this.doesRecordingNavigatePages(); if (root.childNodes.length &gt; 0) { if (root.firstChild.isLeaf()) { // Make a simple chain code = this.generateChain(root); } else { // Group assertions into &quot;it&quot; statements code = root.childNodes.map(this.generateCodeForNode, this).join(&#39;\n\n&#39;); } } // If recording navigates between pages we need to force enablePageRedirect option or test execution will break if (isPageNav) { return &#39;describe({\n name : &quot;&#39; + name + &#39;&quot;,&#39; + &#39;\n enablePageRedirect : true\n}, function(t) {\n&#39; + code + &#39;\n});&#39; } else { return &#39;describe(&quot;&#39; + name + &#39;&quot;, function(t) {\n&#39; + code + &#39;\n});&#39; } }, doesRecordingNavigatePages : function() { var pageNav = false; this.getRoot().cascadeBy(function(node) { if (node.get(&#39;waitForPageLoad&#39;)) { pageNav = true; return false; } }); return pageNav; }, generateCodeForNode : function (node) { if (node.isLeaf()) { return this.getIndent(node.data.depth + 1) + node.asCode(); } if (node.get(&#39;action&#39;) === &#39;group&#39;) { return this.generateIt(node); } }, generateIt : function (node) { var indent = this.getIndent(node.data.depth); var itPre = indent + &#39;t.it(&quot;&#39; + (node.get(&#39;value&#39;) || &#39;should...&#39;) + &#39;&quot;, function(t) {\n&#39;; var itPost = &#39;\n&#39; + indent + &#39;});&#39;; return itPre + this.generateChain(node) + itPost; }, generateChain : function (node) { var me = this; var indent = this.getIndent(node.data.depth + 1); var chainPre = indent + &#39;t.chain(\n&#39;; var chainPost = &#39;\n&#39; + indent + &#39;);&#39;; var codeForSteps = node.childNodes.map(function (step) { return me.generateCodeForNode(step); }).join(&#39;,\n\n&#39;); return chainPre + codeForSteps + chainPost; }, getIndent : function (tabs) { return new Array((this.tabSize * tabs) + 1).join(&#39; &#39;); } }); </pre> </body> </html>