siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
1 lines • 17.3 kB
JavaScript
Ext.data.JsonP.Siesta_Test_Observable({"tagname":"class","name":"Siesta.Test.Observable","autodetected":{},"files":[{"filename":"Observable.js","href":"Observable2.html#Siesta-Test-Observable"}],"members":[{"name":"firesAtLeastNTimes","tagname":"method","owner":"Siesta.Test.Observable","id":"method-firesAtLeastNTimes","meta":{}},{"name":"firesOk","tagname":"method","owner":"Siesta.Test.Observable","id":"method-firesOk","meta":{}},{"name":"firesOnce","tagname":"method","owner":"Siesta.Test.Observable","id":"method-firesOnce","meta":{}},{"name":"isFiredWithSignature","tagname":"method","owner":"Siesta.Test.Observable","id":"method-isFiredWithSignature","meta":{}},{"name":"isntFired","tagname":"method","owner":"Siesta.Test.Observable","id":"method-isntFired","meta":{}},{"name":"waitForEvent","tagname":"method","owner":"Siesta.Test.Observable","id":"method-waitForEvent","meta":{}},{"name":"willFireNTimes","tagname":"method","owner":"Siesta.Test.Observable","id":"method-willFireNTimes","meta":{}},{"name":"wontFire","tagname":"method","owner":"Siesta.Test.Observable","id":"method-wontFire","meta":{}}],"alternateClassNames":[],"aliases":{},"id":"class-Siesta.Test.Observable","component":false,"superclasses":[],"subclasses":[],"mixedInto":[],"mixins":[],"parentMixins":[],"requires":[],"uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Files</h4><div class='dependency'><a href='source/Observable2.html#Siesta-Test-Observable' target='_blank'>Observable.js</a></div></pre><div class='doc-contents'><p>This is a mixin, with assertions/ helper methods for testing observable pattern (in NodeJS world known as <code>EventEmitter</code>).</p>\n</div><div class='members'><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-method'>Methods</h3><div class='subsection'><div id='method-firesAtLeastNTimes' class='member first-child not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-firesAtLeastNTimes' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-firesAtLeastNTimes' class='name expandable'>firesAtLeastNTimes</a>( <span class='pre'>observable, event, n, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion passes if the observable fires the specified event at least n times after calling this method. ...</div><div class='long'><p>This assertion passes if the observable fires the specified event at least <code>n</code> times after calling this method.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Mixed<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>event</span> : String<div class='sub-desc'><p>The name of event</p>\n</div></li><li><span class='pre'>n</span> : Number<div class='sub-desc'><p>The minimum number of events to be fired</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div><div id='method-firesOk' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-firesOk' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-firesOk' class='name expandable'>firesOk</a>( <span class='pre'>options</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion verifies the number of certain events fired by the provided observable instance during provided functi...</div><div class='long'><p>This assertion verifies the number of certain events fired by the provided observable instance during provided function (possibly <code>async</code>) or time period.</p>\n\n<p>For example:</p>\n\n<pre><code>t.firesOk({\n observable : store,\n events : {\n update : 1,\n add : 2,\n datachanged : '> 1'\n },\n during : function () {\n store.getAt(0).set('Foo', 'Bar');\n\n store.add({ FooBar : 'BazQuix' })\n store.add({ Foo : 'Baz' })\n },\n desc : 'Correct events fired'\n})\n\n// or async\n\nawait t.firesOk({\n observable : someObservable,\n events : {\n datachanged : '> 1'\n },\n during : async () => {\n await someObservable.loadData()\n },\n desc : 'Correct events fired'\n})\n\n// or\n\nt.firesOk({\n observable : store,\n events : {\n update : 1,\n add : 2,\n datachanged : '>= 1'\n },\n during : 1\n})\n\nstore.getAt(0).set('Foo', 'Bar');\n\nstore.add({ FooBar : 'BazQuix' })\nstore.add({ Foo : 'Baz' })\n</code></pre>\n\n<p>Normally this method accepts a single object with various options (as shown above), but also can be called in 2 additional shortcuts forms:</p>\n\n<pre><code>// 1st form for multiple events\nt.firesOk(observable, { event1 : 1, event2 : '>1' }, description)\n\n// 2nd form for single event\nt.firesOk(observable, eventName, 1, description)\nt.firesOk(observable, eventName, '>1', description)\n</code></pre>\n\n<p>In both forms, <code>during</code> is assumed to be undefined and <code>description</code> is optional.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>options</span> : Object<div class='sub-desc'><p>An obect with the following properties:</p>\n<ul><li><span class='pre'>observable</span> : Ext.util.Observable/Ext.Element/HTMLElement<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>events</span> : Object<div class='sub-desc'><p>The object, properties of which corresponds to event names and values - to expected\nnumber of this event triggering. If value of some property is a number then exact that number of events is expected. If value\nof some property is a string starting with one of the comparison operators like \"\\<\", \"\\<=\", \"==\" etc and followed by the number\nthen Siesta will perform that comparison with the number of actualy fired events.</p>\n</div></li><li><span class='pre'>during</span> : Number/Function (optional)<div class='sub-desc'><p>If provided as a number denotes the number of milliseconds during which\nthis assertion will \"record\" the events from observable, if provided as regular function - then this assertion will \"record\"\nonly events fired during execution of this function (<code>async</code> functions are supported, in this case, don't forget to <code>await</code>\non the assertion call itself). If not provided at all - assertions are recorded until the end of\ncurrent test (or sub-test)</p>\n</div></li><li><span class='pre'>callback</span> : Function (optional)<div class='sub-desc'><p>A callback to call after this assertion has been checked. Only used if <code>during</code> value is provided.</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>A description for this assertion</p>\n</div></li></ul></div></li></ul></div></div></div><div id='method-firesOnce' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-firesOnce' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-firesOnce' class='name expandable'>firesOnce</a>( <span class='pre'>observable, event, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion passes if the observable fires the specified event exactly once after calling this method. ...</div><div class='long'><p>This assertion passes if the observable fires the specified event exactly once after calling this method.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Mixed<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>event</span> : String/Array[String]<div class='sub-desc'><p>The name of event or array of such</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div><div id='method-isFiredWithSignature' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-isFiredWithSignature' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-isFiredWithSignature' class='name expandable'>isFiredWithSignature</a>( <span class='pre'>observable, event, checkerFn, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion will verify that the observable fires the specified event and supplies the correct parameters to the l...</div><div class='long'><p>This assertion will verify that the observable fires the specified event and supplies the correct parameters to the listener function.\nA checker method should be supplied that verifies the arguments passed to the listener function, and then returns true or false depending on the result.\nIf the event was never fired, this assertion fails. If the event is fired multiple times, all events will be checked, but\nonly one pass/fail message will be reported.</p>\n\n<p>For example:</p>\n\n<pre><code>t.isFiredWithSignature(store, 'add', function (store, records, index) {\n return (store instanceof Ext.data.Store) && (records instanceof Array) && t.typeOf(index) == 'Number'\n})\n</code></pre>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Ext.util.Observable/Siesta.Test.ActionTarget<div class='sub-desc'><p>Ext.util.Observable instance or target as specified by the <a href=\"#!/api/Siesta.Test.ActionTarget\" rel=\"Siesta.Test.ActionTarget\" class=\"docClass\">Siesta.Test.ActionTarget</a> rules with\nthe only difference that component queries will be resolved till the component level, and not the DOM element.</p>\n</div></li><li><span class='pre'>event</span> : String<div class='sub-desc'><p>The name of event</p>\n</div></li><li><span class='pre'>checkerFn</span> : Function<div class='sub-desc'><p>A method that should verify each argument, and return true or false depending on the result.</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div><div id='method-isntFired' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-isntFired' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-isntFired' class='name expandable'>isntFired</a>( <span class='pre'>observable, event, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>Alias for wontFire method ...</div><div class='long'><p>Alias for <a href=\"#!/api/Siesta.Test.Observable-method-wontFire\" rel=\"Siesta.Test.Observable-method-wontFire\" class=\"docClass\">wontFire</a> method</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Mixed<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>event</span> : String/Array[String]<div class='sub-desc'><p>The name of event or array of such</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div><div id='method-waitForEvent' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-waitForEvent' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-waitForEvent' class='name expandable'>waitForEvent</a>( <span class='pre'>observable, event, callback, scope, timeout</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This method will wait for the first browser event, fired by the provided observable and will then call the provided c...</div><div class='long'><p>This method will wait for the first browser <code>event</code>, fired by the provided <code>observable</code> and will then call the provided callback.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Mixed<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>event</span> : String<div class='sub-desc'><p>The name of the event to wait for</p>\n</div></li><li><span class='pre'>callback</span> : Function<div class='sub-desc'><p>The callback to call</p>\n</div></li><li><span class='pre'>scope</span> : Object<div class='sub-desc'><p>The scope for the callback</p>\n</div></li><li><span class='pre'>timeout</span> : Number<div class='sub-desc'><p>The maximum amount of time to wait for the condition to be fulfilled. Defaults to the <a href=\"#!/api/Siesta.Test.ExtJS-cfg-waitForTimeout\" rel=\"Siesta.Test.ExtJS-cfg-waitForTimeout\" class=\"docClass\">Siesta.Test.ExtJS.waitForTimeout</a> value.</p>\n</div></li></ul></div></div></div><div id='method-willFireNTimes' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-willFireNTimes' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-willFireNTimes' class='name expandable'>willFireNTimes</a>( <span class='pre'>observable, event, n, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion passes if the observable fires the specified event exactly (n) times during the test execution. ...</div><div class='long'><p>This assertion passes if the observable fires the specified event exactly (n) times during the test execution.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Ext.util.Observable/Ext.Element/HTMLElement<div class='sub-desc'><p>The observable instance</p>\n</div></li><li><span class='pre'>event</span> : String<div class='sub-desc'><p>The name of event</p>\n</div></li><li><span class='pre'>n</span> : Number<div class='sub-desc'><p>The expected number of events to be fired</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div><div id='method-wontFire' class='member not-inherited'><a href='#' class='side expandable'><span> </span></a><div class='title'><div class='meta'><span class='defined-in' rel='Siesta.Test.Observable'>Siesta.Test.Observable</span><br/><a href='source/Observable2.html#Siesta-Test-Observable-method-wontFire' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.Observable-method-wontFire' class='name expandable'>wontFire</a>( <span class='pre'>observable, event, [desc]</span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This assertion passes if the observable does not fire the specified event(s) after calling this method. ...</div><div class='long'><p>This assertion passes if the observable does not fire the specified event(s) after calling this method.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>observable</span> : Mixed<div class='sub-desc'><p>Any browser observable, window object, element instances, CSS selector.</p>\n</div></li><li><span class='pre'>event</span> : String/Array[String]<div class='sub-desc'><p>The name of event or array of such</p>\n</div></li><li><span class='pre'>desc</span> : String (optional)<div class='sub-desc'><p>The description of the assertion.</p>\n</div></li></ul></div></div></div></div></div></div></div>","meta":{}});