UNPKG

siesta-lite

Version:

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

266 lines (199 loc) 8.48 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.UI.AssertionGrid&#39;, { alias : &#39;widget.assertiongrid&#39;, extend : &#39;Ext.tree.Panel&#39;, mixins : [ &#39;Siesta.Project.Browser.UI.CanFillAssertionsStore&#39; ], requires : [ &#39;Siesta.Project.Browser.Model.AssertionTreeStore&#39;, &#39;Siesta.Project.Browser.UI.FilterableTreeView&#39;, &#39;Siesta.Project.Browser.UI.AssertionTreeColumn&#39; ], cls : &#39;siesta-assertion-grid&#39;, enableColumnHide : false, enableColumnMove : false, enableColumnResize : false, sortableColumns : false, useArrows : true, border : false, minWidth : 100, trackMouseOver : false, autoScrollToBottom : true, hideHeaders : true, rowLines : false, rootVisible : false, collapseDirection : &#39;left&#39;, viewType : &#39;filterabletreeview&#39;, lines : false, disableSelection : true, bufferedRenderer : false, isStandalone : false, test : null, testListeners : null, initComponent : function () { var me = this; this.testListeners = [] if (!this.store) this.store = new Siesta.Project.Browser.Model.AssertionTreeStore({ proxy : &#39;memory&#39;, root : { id : &#39;__ROOT__&#39;, expanded : true, loaded : true } }) Ext.apply(this, { columns : [ this.assertionColumn = new Siesta.Project.Browser.UI.AssertionTreeColumn() ], viewConfig : { enableTextSelection : true, stripeRows : false, markDirty : false, // Animation is disabled until: http://www.sencha.com/forum/showthread.php?265901-4.2.0-Animation-breaks-the-order-of-nodes-in-the-tree-view&amp;p=974172 // is resolved animate : false, trackOver : false, // dummy store to be re-defined before showing each test store : new Ext.data.Store({ fields : [], data : [] }), // this should be kept `false` - otherwise assertion grid goes crazy, see #477 deferInitialRefresh : false, getRowClass : this.getRowClass }, listeners : { itemexpand : this.adaptColumnSize, scope : this } }); this.callParent(arguments); this.getView().on(&#39;itemadd&#39;, this.onMyItemAdd, this); }, onMyItemAdd : function (records) { // Scroll to bottom when test is running if (!this.test.isFinished() &amp;&amp; this.autoScrollToBottom) { this.ensureVisible(records[0]); } }, getRowClass : function (record, rowIndex, rowParams, store) { var result = record.getResult() var cls = &#39;&#39; // TODO switch to &quot;instanceof&quot; switch (result.meta.name) { case &#39;Siesta.Result.Diagnostic&#39;: return &#39;tr-diagnostic-row &#39; + (result.isWarning ? &#39;tr-warning-row&#39; : &#39;&#39;); case &#39;Siesta.Result.Summary&#39;: return &#39;tr-summary-row &#39; + (result.isFailed ? &#39; tr-summary-failure&#39; : &#39;&#39;); case &#39;Siesta.Result.SubTest&#39;: cls = &#39;tr-subtest-row tr-subtest-row-&#39; + record.get(&#39;folderStatus&#39;) if (result.test.specType == &#39;describe&#39;) cls += &#39; tr-subtest-row-describe&#39; if (result.test.specType == &#39;it&#39;) cls += &#39; tr-subtest-row-it&#39; return cls; case &#39;Siesta.Result.Assertion&#39;: cls += &#39;tr-assertion-row &#39; if (result.isWaitFor) cls += &#39;tr-waiting-row &#39; + (result.completed ? (result.passed ? &#39;tr-waiting-row-passed&#39; : &#39;tr-assertion-row-failed tr-waiting-row-failed&#39;) : &#39;&#39;) else if (result.isException) cls += result.isTodo ? &#39;tr-exception-todo-row&#39; : &#39;tr-exception-row&#39; else if (result.isTodo) cls += result.passed ? &#39;tr-todo-row-passed&#39; : &#39;tr-todo-row-failed&#39; else cls += result.passed ? &#39;tr-assertion-row-passed&#39; : &#39;tr-assertion-row-failed&#39; return cls default: throw &quot;Unknown result class&quot; } }, showTest : function (test, assertionsStore) { if (this.test) { Joose.A.each(this.testListeners, function (listener) { listener.remove() }) this.testListeners = [] } this.test = test this.testListeners = [].concat( this.isStandalone ? [ test.on(&#39;testupdate&#39;, this.onTestUpdate, this), test.on(&#39;testendbubbling&#39;, this.onEveryTestEnd, this), test.on(&#39;assertiondiscard&#39;, this.onAssertionDiscarded, this) ] : [ test.on(&#39;testfinalize&#39;, this.adaptColumnSize, this) ] ) Ext.suspendLayouts() if (assertionsStore) { if (this.store !== assertionsStore) this.reconfigure(assertionsStore) } else if (this.getStore().getRoot().childNodes.length &gt; 0) this.store.removeAll() Ext.resumeLayouts() }, onTestUpdate : function (event, test, result, parentResult) { this.processNewResult(this.store, test, result, parentResult) }, adaptColumnSize : function () { var headerCt = this.getHeaderContainer(); var maxWidth = this.getView().getMaxContentWidth(this.assertionColumn); // HACK private method this.assertionColumn.setWidth(Math.max(maxWidth, this.getWidth())); }, onResize : function() { this.callParent(arguments); this.adaptColumnSize(); }, // is bubbling and thus triggered for all tests (including sub-tests) onEveryTestEnd : function (event, test) { this.processEveryTestEnd(this.store, test) }, onAssertionDiscarded : function(event, test, result) { this.store.getNodeById(result.id).remove(); }, bindStore : function (treeStore, isInitial, prop) { this.callParent(arguments) this.store = treeStore; if (treeStore &amp;&amp; treeStore.nodeStore) { this.getView().dataSource = treeStore.nodeStore // passing the tree store instance to the underlying `filterabletreeview` // the view will re-bind the tree store listeners this.getView().bindStore(treeStore, isInitial, prop) } }, destroy : function () { Joose.A.each(this.testListeners, function (listener) { listener.remove() }) this.testListeners = [] this.test = null this.callParent(arguments) }, setInitializing : function (initializing) { if (initializing) { this.getView().addCls(&#39;siesta-test-initializing&#39;); } else { this.getView().removeCls(&#39;siesta-test-initializing&#39;); } } }) </pre> </body> </html>