UNPKG

siesta-lite

Version:

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

154 lines (111 loc) 4.34 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.Project.Browser.Model.Assertion&#39;, { extend : &#39;Ext.data.Model&#39;, idProperty : &#39;id&#39;, proxy : { type : &#39;memory&#39; }, fields : [ &#39;id&#39;, { name : &#39;folderStatus&#39;, defaultValue : &#39;yellow&#39; }, // the Siesta.Result instance itself { name : &#39;result&#39; } ], getResult : function () { return this.data.result }, isAssertion : function () { return this.data.result instanceof Siesta.Result.Assertion }, isDiagnostic : function () { return this.data.result instanceof Siesta.Result.Diagnostic }, isSummary : function () { return this.data.result instanceof Siesta.Result.Summary }, ensureVisible : function () { var parent = this.parentNode while (parent &amp;&amp; !parent.isRoot()) { parent.expand() parent = parent.parentNode } }, isWaitingAssertion : function () { var result = this.data.result return this.isAssertion() &amp;&amp; result.isWaiting &amp;&amp; !result.completed }, updateFolderStatus : function () { if (!this.isLeaf()) this.set(&#39;folderStatus&#39;, this.computeFolderStatus()) var parentNode = this.parentNode if (parentNode &amp;&amp; !parentNode.isRoot()) parentNode.updateFolderStatus() }, triggerUIUpdate: function(){ // This isn&#39;t ideal, however none of the underlying fields have changed // but we still need to update the UI this.callJoined(&#39;afterEdit&#39;, []); }, computeFolderStatus : function () { if (!this.isLeaf() &amp;&amp; this.getResult().isWorking()) return &#39;working&#39; if (!this.childNodes.length) return &#39;yellow&#39; var isWorking = false var hasFailed = false var allGreen = true Joose.A.each(this.childNodes, function (childNode) { var result = childNode.getResult() if (childNode.isLeaf()) { if (childNode.isWaitingAssertion()) isWorking = true if (childNode.isAssertion()) { if (!result.isPassed()) { allGreen = false hasFailed = true // stop iteration return false } } } else { var status = childNode.computeFolderStatus() if (status == &#39;red&#39;) { allGreen = false hasFailed = true // stop iteration return false } if (result.isWorking() || status == &#39;working&#39;) { isWorking = true // stop iteration return false } if (status == &#39;yellow&#39;) allGreen = false } }) if (isWorking) return &#39;working&#39; if (hasFailed) return &#39;red&#39; if (allGreen) return &#39;green&#39; return &#39;yellow&#39; } }); </pre> </body> </html>