siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
1 lines • 13.4 kB
JavaScript
Ext.data.JsonP.Siesta_Test_BDD_Spy({"tagname":"class","name":"Siesta.Test.BDD.Spy","autodetected":{},"files":[{"filename":"Spy.js","href":"Spy.html#Siesta-Test-BDD-Spy"}],"members":[{"name":"and","tagname":"property","owner":"Siesta.Test.BDD.Spy","id":"property-and","meta":{}},{"name":"calls","tagname":"property","owner":"Siesta.Test.BDD.Spy","id":"property-calls","meta":{}},{"name":"callFake","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-callFake","meta":{"chainable":true}},{"name":"callThrough","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-callThrough","meta":{"chainable":true}},{"name":"reset","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-reset","meta":{}},{"name":"returnValue","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-returnValue","meta":{"chainable":true}},{"name":"stub","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-stub","meta":{"chainable":true}},{"name":"throwError","tagname":"method","owner":"Siesta.Test.BDD.Spy","id":"method-throwError","meta":{"chainable":true}}],"alternateClassNames":[],"aliases":{},"id":"class-Siesta.Test.BDD.Spy","short_doc":"This class implements a \"spy\" - function wrapper which tracks the calls to itself. ...","component":false,"superclasses":[],"subclasses":[],"mixedInto":[],"mixins":[],"parentMixins":[],"requires":[],"uses":[],"html":"<div><pre class=\"hierarchy\"><h4>Files</h4><div class='dependency'><a href='source/Spy.html#Siesta-Test-BDD-Spy' target='_blank'>Spy.js</a></div></pre><div class='doc-contents'><p>This class implements a \"spy\" - function wrapper which tracks the calls to itself. Spy can be installed\ninstead of a method in some object or can be used standalone.</p>\n\n<p>Note, that spies \"belongs\" to a spec and once the spec is completed all spies that were installed during it\nwill be removed.</p>\n</div><div class='members'><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-property'>Properties</h3><div class='subsection'><div id='property-and' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-property-and' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-property-and' class='name expandable'>and</a> : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"></span></div><div class='description'><div class='short'>This is just a reference to itself, to add some syntax sugar. ...</div><div class='long'><p>This is just a reference to itself, to add some syntax sugar.</p>\n\n<p>This property is also assigned to the wrapper function of spy.</p>\n\n<pre><code>t.spyOn(obj, 'someMethod').callThrough()\n\n// same thing as above\nt.spyOn(obj, 'someMethod').and.callThrough()\n\n// returns spy instance\nobj.someMethod.and\n</code></pre>\n</div></div></div><div id='property-calls' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-property-calls' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-property-calls' class='name expandable'>calls</a> : Object<span class=\"signature\"></span></div><div class='description'><div class='short'>This is an object property with several helper methods, related to the calls\ntracking information. ...</div><div class='long'><p>This is an object property with several helper methods, related to the calls\ntracking information. It is assigned to the wrapper function of spy.</p>\n<ul><li><span class='pre'>any</span> : Function<div class='sub-desc'><p>Returns <code>true</code> if spy was called at least once, <code>false</code> otherwise</p>\n</div></li><li><span class='pre'>count</span> : Function<div class='sub-desc'><p>Returns the number of times this spy was called</p>\n</div></li><li><span class='pre'>argsFor</span> : Function<div class='sub-desc'><p>Accepts an number of the call (0-based) and return an array of arguments\nfor that call.</p>\n</div></li><li><span class='pre'>allArgs</span> : Function<div class='sub-desc'><p>Returns an array with the arguments for every tracked function call.\nEvery element of the array is, in turn, an array of arguments.</p>\n</div></li><li><span class='pre'>all</span> : Function<div class='sub-desc'><p>Returns an array with the context for every tracked function call.\nEvery element of the array is an object of the following structure:</p>\n\n<pre><code>{ object : this, args : [ 0, 1, 2 ], returnValue : undefined }\n</code></pre>\n</div></li><li><span class='pre'>mostRecent</span> : Function<div class='sub-desc'><p>Returns a context object of the most-recent tracked function call.</p>\n</div></li><li><span class='pre'>first</span> : Function<div class='sub-desc'><p>Returns a context object of the first tracked function call.</p>\n</div></li><li><span class='pre'>reset</span> : Function<div class='sub-desc'><p>Reset all tracking data.</p>\n\n<p>Example:</p>\n\n<pre><code>t.spyOn(obj, 'someMethod').callThrough()\n\nobj.someMethod(0, 1)\nobj.someMethod(1, 2)\n\nt.expect(obj.someMethod.calls.any()).toBe(true)\nt.expect(obj.someMethod.calls.count()).toBe(2)\nt.expect(obj.someMethod.calls.first()).toEqual({ object : obj, args : [ 0, 1 ], returnValue : undefined })\n</code></pre>\n</div></li></ul></div></div></div></div></div><div class='members-section'><div class='definedBy'>Defined By</div><h3 class='members-title icon-method'>Methods</h3><div class='subsection'><div id='method-callFake' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-callFake' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-callFake' class='name expandable'>callFake</a>( <span class='pre'>func</span> ) : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"><span class='chainable' >chainable</span></span></div><div class='description'><div class='short'>This method makes the spy to call the provided function and return the value from it, instead of the original function. ...</div><div class='long'><p>This method makes the spy to call the provided function and return the value from it, instead of the original function.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>func</span> : Function<div class='sub-desc'><p>The function to call instead of the original function</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a></span><div class='sub-desc'><p>This spy instance</p>\n</div></li></ul></div></div></div><div id='method-callThrough' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-callThrough' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-callThrough' class='name expandable'>callThrough</a>( <span class='pre'></span> ) : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"><span class='chainable' >chainable</span></span></div><div class='description'><div class='short'>This method makes the spy to also execute the original function it has been installed over. ...</div><div class='long'><p>This method makes the spy to also execute the original function it has been installed over. The\nvalue returned from original function is returned from the spy.</p>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a></span><div class='sub-desc'><p>This spy instance</p>\n</div></li></ul></div></div></div><div id='method-reset' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-reset' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-reset' class='name expandable'>reset</a>( <span class='pre'></span> )<span class=\"signature\"></span></div><div class='description'><div class='short'>This method resets all calls tracking data. ...</div><div class='long'><p>This method resets all calls tracking data. Spy will report as it has never been called yet.</p>\n</div></div></div><div id='method-returnValue' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-returnValue' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-returnValue' class='name expandable'>returnValue</a>( <span class='pre'>value</span> ) : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"><span class='chainable' >chainable</span></span></div><div class='description'><div class='short'>This method makes the spy to return the value provided and not execute the original function. ...</div><div class='long'><p>This method makes the spy to return the value provided and not execute the original function.</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>value</span> : Object<div class='sub-desc'><p>The value that will be returned from the spy.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a></span><div class='sub-desc'><p>This spy instance</p>\n</div></li></ul></div></div></div><div id='method-stub' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-stub' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-stub' class='name expandable'>stub</a>( <span class='pre'></span> ) : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"><span class='chainable' >chainable</span></span></div><div class='description'><div class='short'>This method makes the spy to just return undefined and not execute the original function. ...</div><div class='long'><p>This method makes the spy to just return <code>undefined</code> and not execute the original function.</p>\n<h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a></span><div class='sub-desc'><p>This spy instance</p>\n</div></li></ul></div></div></div><div id='method-throwError' 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.BDD.Spy'>Siesta.Test.BDD.Spy</span><br/><a href='source/Spy.html#Siesta-Test-BDD-Spy-method-throwError' target='_blank' class='view-source'>view source</a></div><a href='#!/api/Siesta.Test.BDD.Spy-method-throwError' class='name expandable'>throwError</a>( <span class='pre'>error</span> ) : <a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a><span class=\"signature\"><span class='chainable' >chainable</span></span></div><div class='description'><div class='short'>This method makes the spy to throw the specified error value (instead of calling the original function). ...</div><div class='long'><p>This method makes the spy to throw the specified <code>error</code> value (instead of calling the original function).</p>\n<h3 class=\"pa\">Parameters</h3><ul><li><span class='pre'>error</span> : Object<div class='sub-desc'><p>The error value to throw. If it is not an <code>Error</code> instance, it will be passed to <code>Error</code> constructor first.</p>\n</div></li></ul><h3 class='pa'>Returns</h3><ul><li><span class='pre'><a href=\"#!/api/Siesta.Test.BDD.Spy\" rel=\"Siesta.Test.BDD.Spy\" class=\"docClass\">Siesta.Test.BDD.Spy</a></span><div class='sub-desc'><p>This spy instance</p>\n</div></li></ul></div></div></div></div></div></div></div>","meta":{}});