UNPKG

siesta-lite

Version:

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

215 lines (163 loc) 7.4 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-Project-Browser-ExtJS'>/** </span>@class Siesta.Project.Browser.ExtJS @extends Siesta.Project.Browser @mixin Siesta.Project.Browser.ExtJSCore Class, representing the browser project. This class provides a web-based UI and defines some additional configuration options. The default value of the `testClass` configuration option in this class is {@link Siesta.Test.ExtJS}, which inherits from {@link Siesta.Test.Browser} and contains various ExtJS-specific assertions. So, use this project class, when testing an ExtJS application. This file is for reference only, for a getting start guide and manual, please refer to &lt;a href=&quot;#!/guide/getting_started_browser&quot;&gt;Siesta getting started in browser environment&lt;/a&gt; guide. Synopsys ======== var project = new Siesta.Project.Browser.ExtJS(); project.configure({ title : &#39;Awesome ExtJS Application Test Suite&#39;, transparentEx : true, autoCheckGlobals : true, expectedGlobals : [ &#39;Ext&#39;, &#39;Sch&#39; ], preload : [ &quot;http://cdn.sencha.io/ext-4.0.2a/ext-all-debug.js&quot;, &quot;../awesome-project-all.js&quot;, { text : &quot;console.log(&#39;preload completed&#39;)&quot; } ] }) project.plan( // simple string - url relative to project file &#39;sanity.t.js&#39;, // test file descriptor with own configuration options { url : &#39;basic.t.js&#39;, // replace `preload` option of project preload : [ &quot;http://cdn.sencha.io/ext-4.0.6/ext-all-debug.js&quot;, &quot;../awesome-project-all.js&quot; ] }, // groups (&quot;folders&quot;) of test files (possibly with own options) { group : &#39;Sanity&#39;, autoCheckGlobals : false, items : [ &#39;data/crud.t.js&#39;, ... ] }, ... ) */ Class(&#39;Siesta.Project.Browser.ExtJS&#39;, { isa : Siesta.Project.Browser, does : [ Siesta.Project.Browser.ExtJSCore ], has : { <span id='Siesta-Project-Browser-ExtJS-cfg-testClass'> /** </span> * @cfg {Class} testClass The test class which will be used for creating test instances, defaults to {@link Siesta.Test.ExtJS}. * You can subclass {@link Siesta.Test.ExtJS} and provide a new class. * * This option can be also specified in the test file descriptor. */ testClass : Siesta.Test.ExtJS, <span id='Siesta-Project-Browser-ExtJS-cfg-waitForExtReady'> /** </span> * @cfg {Boolean} waitForExtReady * * By default the `StartTest` function will be executed after `Ext.onReady`. Set to `false` to launch `StartTest` immediately. * * This option can be also specified in the test file descriptor. */ waitForExtReady : true, <span id='Siesta-Project-Browser-ExtJS-cfg-waitForAppReady'> /** </span> * @cfg {Boolean} waitForAppReady * * Setting this configuration option to &quot;true&quot; will cause Siesta to wait until the ExtJS MVC application on the test page will become ready, * before starting the test. More precisely, it will wait till the &quot;launched&quot; property of the application, specified * in the `Ext.manifest.name` to be `true`. * * This option can (and probably should) be also specified in the test file descriptor. */ waitForAppReady : false, extVersion : null, <span id='Siesta-Project-Browser-ExtJS-cfg-failOnMultipleComponentMatches'> /** </span> * @cfg {Boolean} failOnMultipleComponentMatches * * True to fail when providing a Component Query matching multiple components. False to warn only. * Component Queries should ideally always be unique to identify only one target in the DOM. */ failOnMultipleComponentMatches : false, extVersionRegExp : /ext(?:js)?-(\d\.\d+\.\d+.*?)\//, contentManagerClass : Siesta.Content.Manager.Browser.ExtJSCore, // Required by Ext JS 6 innerHtmlHead : &#39;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no&quot;&gt;&#39; }, methods : { setup : function (callback) { var me = this /* This is to be able to pass &quot;next&quot; function form the chain step to the Ext as callback: function (next) { resourceStore.reload({ callback : next }) } For some reason, Ext performs &quot;isFunction&quot; check on the callback value and only calls it if this check passes (assuming programmer does not know what he is doing) &quot;isFunction&quot; check in turn relies on the presence of this property in the Function prototype This line can be removed once &quot;isFunction&quot; in Ext will become cross-context or Ext will stop using &quot;isFunction&quot; check for callbacks */ Function.prototype.$extIsFunction = true; this.SUPER(function () { callback() }) }, getNewTestConfiguration : function (desc, scopeProvider, contentManager, launchState) { var config = this.SUPERARG(arguments) config.waitForExtReady = this.getDescriptorConfig(desc, &#39;waitForExtReady&#39;) config.waitForAppReady = this.getDescriptorConfig(desc, &#39;waitForAppReady&#39;) return config }, findExtVersion : function () { var me = this var found this.mainPreset.eachResource(function (resource) { var match = me.extVersionRegExp.exec(resource.url) if (match) { found = match[ 1 ] return false } }) return found } } }) // backward compat Class(&#39;Siesta.Harness.Browser.ExtJS&#39;, { isa : Siesta.Project.Browser.ExtJS })</pre> </body> </html>