selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
23 lines • 23.9 kB
HTML
<meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.testing.StrictMock</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Class goog.testing.StrictMock</h1><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l42">code »</a><pre><code><a href="class_goog_testing_Mock.html">goog.testing.Mock</a>
└ goog.testing.StrictMock</code></pre><dl><dt>All implemented interfaces:<dd><code><a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></dl></header><section><p>This is a mock that verifies that methods are called in the order that they
are specified during the recording phase. Since it verifies order, it
follows 'fail fast' semantics. If it detects a deviation from the
expectations, it will throw an exception and not wait for verify to be
called.<h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">goog.testing.StrictMock <span class="args">( objectToMock, opt_mockStaticMethods, opt_createProxy )</span></span></div><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>objectToMock: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>)</code><dd>The object that should be mocked, or
the constructor of an object to mock.<dt>opt_mockStaticMethods: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>An optional argument denoting that
a mock should be constructed from the static functions of a class.<dt>opt_createProxy: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>An optional argument denoting that
a proxy for the target mock should be created.</dl></table></div></div></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="instance-methods"><h2>Instance Methods</h2><h3>Defined in <code class="type">goog.testing.StrictMock</code></h3><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l64">code »</a><span class="member"><a name="$recordCall">$recordCall</a> <span class="args">( name, args )</span> ⇒ <code class="type">*</code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>name<dt>args</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l58">code »</a><span class="member"><a name="$recordExpectation">$recordExpectation</a> <span class="args">( )</span></span></div></summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l105">code »</a><span class="member"><a name="$reset">$reset</a> <span class="args">( )</span></span></div></summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l113">code »</a><span class="member"><a name="$verify">$verify</a> <span class="args">( )</span></span></div></summary></details></div></div><h3>Defined in <code class="type"><a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></h3><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l487">code »</a><span class="member"><a name="$anyTimes">$anyTimes</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Allows the expectation to be called any number of times.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l603">code »</a><span class="member"><a name="$argumentsAsString">$argumentsAsString</a> <span class="args">( args )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Render the provided argument array to a string to help
clients with debugging tests.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>args: <code class="type">?<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>The arguments passed to the mock.</dl><tr><th>Returns<tr><td><dl>Human-readable string.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l455">code »</a><span class="member"><a name="$atLeastOnce">$atLeastOnce</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Allows the expectation to be called any number of times, as long as it's
called once.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l443">code »</a><span class="member"><a name="$atMostOnce">$atMostOnce</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Allows the expectation to be called 0 or 1 times.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l394">code »</a><span class="member"><a name="$do">$do</a> <span class="args">( expectation, args )</span> ⇒ <code class="type">*</code></span></div><p>If this expectation defines a function to be called,
it will be called and its result will be returned.
Otherwise, if the expectation expects to throw, it will throw.
Otherwise, this method will return defined value.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>expectation: <code class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a></code><dd>The expectation.<dt>args: <code class="type"><a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>The arguments to the method.</dl><tr><th>Returns<tr><td><dl>The return value expected by the mock.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l433">code »</a><span class="member"><a name="$does">$does</a> <span class="args">( func )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Specifies a function to call for currently pending expectation.
Note, that using this method overrides declarations made
using $returns() and $throws() methods.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>func: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to call.</dl><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l282">code »</a><span class="member"><a name="$initializeFunctions_">$initializeFunctions_</a> <span class="args">( objectToMock )</span></span></div><p>Initializes the functions on the mock object.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>objectToMock: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The object being mocked.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l378">code »</a><span class="member"><a name="$maybeThrow">$maybeThrow</a> <span class="args">( expectation )</span></span></div><p>If the expectation expects to throw, this method will throw.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>expectation: <code class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a></code><dd>The expectation.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l333">code »</a><span class="member"><a name="$mockMethod">$mockMethod</a> <span class="args">( name )</span> ⇒ <code class="type">*</code></span></div><p>The function that replaces all methods on the mock object.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>name: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the method being mocked.</dl><tr><th>Returns<tr><td><dl>In record mode, returns the mock object. In replay mode, returns
whatever the creator of the mock set as the return value.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l476">code »</a><span class="member"><a name="$never">$never</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Disallows the expectation from being called.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l465">code »</a><span class="member"><a name="$once">$once</a> <span class="args">( )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Allows the expectation to be called exactly once.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details protected"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l545">code »</a><span class="member"><a name="$recordAndThrow">$recordAndThrow</a> <span class="args">( ex )</span></span></div><p>Throws an exception and records that an exception was thrown.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ex: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>Exception.</dl><tr><th>Throws<tr><td><dl><dt><code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>#ex.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l320">code »</a><span class="member"><a name="$registerArgumentListVerifier">$registerArgumentListVerifier</a> <span class="args">( methodName, fn )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Registers a verfifier function to use when verifying method argument lists.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>methodName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the method for which the verifierFn
should be used.<dt>fn: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>Argument list verifier function. Should take 2 argument
arrays as arguments, and return true if they are considered equivalent.</dl><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l510">code »</a><span class="member"><a name="$replay">$replay</a> <span class="args">( )</span></span></div><p>Switches from recording to replay mode.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l409">code »</a><span class="member"><a name="$returns">$returns</a> <span class="args">( val )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Specifies a return value for the currently pending expectation.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>val: <code class="type">*</code><dd>The return value.</dl><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l623">code »</a><span class="member"><a name="$throwCallException">$throwCallException</a> <span class="args">( name, args, opt_expectation )</span></span></div><p>Throw an exception based on an incorrect method call.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>name: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Name of method called.<dt>args: <code class="type">?<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>Arguments passed to the mock.<dt>opt_expectation: <code class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a>=</code><dd>Expected next call,
if any.</dl></table></div></details></div></div><div class="wrap-details protected"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l534">code »</a><span class="member"><a name="$throwException">$throwException</a> <span class="args">( comment, opt_message )</span></span></div><p>Throws an exception and records that an exception was thrown.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>comment: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A short comment about the exception.<dt>opt_message: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>A longer message about the exception.</dl><tr><th>Throws<tr><td><dl><dt><code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>JsUnitException object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l420">code »</a><span class="member"><a name="$throws">$throws</a> <span class="args">( val )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Specifies a value for the currently pending expectation to throw.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>val: <code class="type">*</code><dd>The value to throw.</dl><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l499">code »</a><span class="member"><a name="$times">$times</a> <span class="args">( times )</span> ⇒ <code class="type">!<a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></span></div><p>Specifies the number of times the expectation should be called.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>times: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The number of times this method will be called.</dl><tr><th>Returns<tr><td><dl>This mock object.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l584">code »</a><span class="member"><a name="$verifyCall">$verifyCall</a> <span class="args">( expectation, name, args )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Verifies that a method call matches an expectation.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>expectation: <code class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a></code><dd>The expectation to check.<dt>name: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the called method.<dt>args: <code class="type">?<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>The arguments passed to the mock.</dl><tr><th>Returns<tr><td><dl>Whether the call matches the expectation.</dl></table></div></details></div></div></section><section id="instance-properties"><h2>Instance Properties</h2><h3>Defined in <code class="type">goog.testing.StrictMock</code></h3><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l52">code »</a><span class="member"><a name="$expectations_">$expectations_</a> : <code class="type"><a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.<<a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a>></code></span></div><p>An array of MockExpectations.</summary></details></div></div><h3>Defined in <code class="type"><a href="class_goog_testing_Mock.html">goog.testing.Mock</a></code></h3><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l248">code »</a><span class="member"><a name="$argumentListVerifiers_">$argumentListVerifiers_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code></span></div><p>Map of argument name to optional argument list verifier function.</summary></details></div></div><div class="wrap-details protected"><div><details><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l266">code »</a><span class="member"><a name="$pendingExpectation">$pendingExpectation</a> : <code class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a></code></span></div><p>The expectation currently being created. All methods that modify the
current expectation return the Mock object for easy chaining, so this is
where we keep track of the expectation that's currently being modified.</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l241">code »</a><span class="member"><a name="$proxy">$proxy</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code></span></div><p>A proxy for the mock. This can be used for dependency injection in lieu of
the mock if the test requires a strict instanceof check.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l256">code »</a><span class="member"><a name="$recording_">$recording_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Whether or not we are in recording mode.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/testing/mock.js.src.html#l274">code »</a><span class="member"><a name="$threwException_">$threwException_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code></span></div><p>First exception thrown by this mock; used in $verify.</summary></details></div></div></section><section id="static-properties"><h2>Static Properties</h2><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/testing/strictmock.js.src.html#l42">code »</a><span class="member"><a name="goog.testing.StrictMock.superClass_">goog.testing.StrictMock.superClass_</a> : <code class="type"><a href="class_goog_testing_Mock.html">goog.testing.Mock.prototype</a></code></span></div></summary></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>Loading</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>Loading</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>Loading</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script>