UNPKG

siesta-lite

Version:

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

79 lines (66 loc) 3.07 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-ExtJS-DataView'>/** </span>@class Siesta.Test.ExtJS.DataView This is a mixin, with helper methods for testing functionality relating to ExtJS dataviews. This mixin is being consumed by {@link Siesta.Test.ExtJS} */ Role(&#39;Siesta.Test.ExtJS.DataView&#39;, { requires : [ &#39;waitFor&#39;, &#39;getExt&#39; ], methods : { <span id='Siesta-Test-ExtJS-DataView-method-waitForViewRendered'> /** </span> * Waits for the items of a dataview to render and then calls the supplied callback. * @param {Ext.view.View/String} view An Ext.view.View instance or a ComponentQuery * @param {Function} callback A function to call when the condition has been met. * @param {Object} scope The scope for the callback * @param {Int} timeout The maximum amount of time to wait for the condition to be fulfilled. Defaults to the {@link Siesta.Test.ExtJS#waitForTimeout} value. */ waitForViewRendered : function(view, callback, scope, timeout) { view = this.normalizeComponent(view); var hasItems = view &amp;&amp; view.store &amp;&amp; view.store.getCount() &gt; 0 var R = Siesta.Resource(&#39;Siesta.Test.ExtJS.DataView&#39;); return this.waitFor({ method : function() { return hasItems ? !!view.getNode(0) : view.rendered }, callback : callback, scope : scope, timeout : timeout, assertionName : &#39;waitForViewRendered&#39;, description : &#39; &#39; + R.get(&#39;view&#39;) + &#39; &#39; + view.id + &#39; &#39; + R.get(&#39;toRender&#39;) }); }, <span id='Siesta-Test-ExtJS-DataView-method-getFirstItem'> /** </span> * Utility method which returns the first view element. * * @param {Ext.view.View/String} view An Ext.view.View instance or a ComponentQuery * @return {Ext.Element} The first element of the view */ getFirstItem : function(view) { var Ext = this.getExt(); view = this.normalizeComponent(view); return Ext.get(view.getNode(0)); } } }); </pre> </body> </html>