UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

1 lines 7.11 kB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>matcher.js</title><link href="../../../../../dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>lib/goog/labs/testing/matcher.js</h1></header><pre><table class="srcfile"><tbody><tr><td><a name="l1" href="#l1">1</a><td>// Copyright 2012 The Closure Library Authors. All Rights Reserved.<tr><td><a name="l2" href="#l2">2</a><td>//<tr><td><a name="l3" href="#l3">3</a><td>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<tr><td><a name="l4" href="#l4">4</a><td>// you may not use this file except in compliance with the License.<tr><td><a name="l5" href="#l5">5</a><td>// You may obtain a copy of the License at<tr><td><a name="l6" href="#l6">6</a><td>//<tr><td><a name="l7" href="#l7">7</a><td>// http://www.apache.org/licenses/LICENSE-2.0<tr><td><a name="l8" href="#l8">8</a><td>//<tr><td><a name="l9" href="#l9">9</a><td>// Unless required by applicable law or agreed to in writing, software<tr><td><a name="l10" href="#l10">10</a><td>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,<tr><td><a name="l11" href="#l11">11</a><td>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<tr><td><a name="l12" href="#l12">12</a><td>// See the License for the specific language governing permissions and<tr><td><a name="l13" href="#l13">13</a><td>// limitations under the License.<tr><td><a name="l14" href="#l14">14</a><td><tr><td><a name="l15" href="#l15">15</a><td>/**<tr><td><a name="l16" href="#l16">16</a><td> * @fileoverview Provides the base Matcher interface. User code should use the<tr><td><a name="l17" href="#l17">17</a><td> * matchers through assertThat statements and not directly.<tr><td><a name="l18" href="#l18">18</a><td> */<tr><td><a name="l19" href="#l19">19</a><td><tr><td><a name="l20" href="#l20">20</a><td><tr><td><a name="l21" href="#l21">21</a><td>goog.provide(&#39;goog.labs.testing.Matcher&#39;);<tr><td><a name="l22" href="#l22">22</a><td><tr><td><a name="l23" href="#l23">23</a><td><tr><td><a name="l24" href="#l24">24</a><td><tr><td><a name="l25" href="#l25">25</a><td>/**<tr><td><a name="l26" href="#l26">26</a><td> * A matcher object to be used in assertThat statements.<tr><td><a name="l27" href="#l27">27</a><td> * @interface<tr><td><a name="l28" href="#l28">28</a><td> */<tr><td><a name="l29" href="#l29">29</a><td>goog.labs.testing.Matcher = function() {};<tr><td><a name="l30" href="#l30">30</a><td><tr><td><a name="l31" href="#l31">31</a><td><tr><td><a name="l32" href="#l32">32</a><td>/**<tr><td><a name="l33" href="#l33">33</a><td> * Determines whether a value matches the constraints of the match.<tr><td><a name="l34" href="#l34">34</a><td> *<tr><td><a name="l35" href="#l35">35</a><td> * @param {*} value The object to match.<tr><td><a name="l36" href="#l36">36</a><td> * @return {boolean} Whether the input value matches this matcher.<tr><td><a name="l37" href="#l37">37</a><td> */<tr><td><a name="l38" href="#l38">38</a><td>goog.labs.testing.Matcher.prototype.matches = function(value) {};<tr><td><a name="l39" href="#l39">39</a><td><tr><td><a name="l40" href="#l40">40</a><td><tr><td><a name="l41" href="#l41">41</a><td>/**<tr><td><a name="l42" href="#l42">42</a><td> * Describes why the matcher failed.<tr><td><a name="l43" href="#l43">43</a><td> *<tr><td><a name="l44" href="#l44">44</a><td> * @param {*} value The value that didn&#39;t match.<tr><td><a name="l45" href="#l45">45</a><td> * @param {string=} opt_description A partial description to which the reason<tr><td><a name="l46" href="#l46">46</a><td> * will be appended.<tr><td><a name="l47" href="#l47">47</a><td> *<tr><td><a name="l48" href="#l48">48</a><td> * @return {string} Description of why the matcher failed.<tr><td><a name="l49" href="#l49">49</a><td> */<tr><td><a name="l50" href="#l50">50</a><td>goog.labs.testing.Matcher.prototype.describe =<tr><td><a name="l51" href="#l51">51</a><td> function(value, opt_description) {};<tr><td><a name="l52" href="#l52">52</a><td><tr><td><a name="l53" href="#l53">53</a><td><tr><td><a name="l54" href="#l54">54</a><td>/**<tr><td><a name="l55" href="#l55">55</a><td> * Generates a Matcher from the ‘matches’ and ‘describe’ functions passed in.<tr><td><a name="l56" href="#l56">56</a><td> *<tr><td><a name="l57" href="#l57">57</a><td> * @param {!Function} matchesFunction The ‘matches’ function.<tr><td><a name="l58" href="#l58">58</a><td> * @param {Function=} opt_describeFunction The ‘describe’ function.<tr><td><a name="l59" href="#l59">59</a><td> * @return {!Function} The custom matcher.<tr><td><a name="l60" href="#l60">60</a><td> */<tr><td><a name="l61" href="#l61">61</a><td>goog.labs.testing.Matcher.makeMatcher =<tr><td><a name="l62" href="#l62">62</a><td> function(matchesFunction, opt_describeFunction) {<tr><td><a name="l63" href="#l63">63</a><td><tr><td><a name="l64" href="#l64">64</a><td> /**<tr><td><a name="l65" href="#l65">65</a><td> * @constructor<tr><td><a name="l66" href="#l66">66</a><td> * @implements {goog.labs.testing.Matcher}<tr><td><a name="l67" href="#l67">67</a><td> * @final<tr><td><a name="l68" href="#l68">68</a><td> */<tr><td><a name="l69" href="#l69">69</a><td> var matcherConstructor = function() {};<tr><td><a name="l70" href="#l70">70</a><td><tr><td><a name="l71" href="#l71">71</a><td> /** @override */<tr><td><a name="l72" href="#l72">72</a><td> matcherConstructor.prototype.matches = matchesFunction;<tr><td><a name="l73" href="#l73">73</a><td><tr><td><a name="l74" href="#l74">74</a><td> if (opt_describeFunction) {<tr><td><a name="l75" href="#l75">75</a><td> /** @override */<tr><td><a name="l76" href="#l76">76</a><td> matcherConstructor.prototype.describe = opt_describeFunction;<tr><td><a name="l77" href="#l77">77</a><td> }<tr><td><a name="l78" href="#l78">78</a><td><tr><td><a name="l79" href="#l79">79</a><td> return matcherConstructor;<tr><td><a name="l80" href="#l80">80</a><td>};</table></pre></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>