# testing/assert.js

1 | // Copyright 2013 Software Freedom Conservancy
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /**
16 | * @fileoverview Defines a library that simplifies writing assertions against
17 | * promised values.
18 | *
19 | * > <hr>
20 | * > __NOTE:__ This module is considered experimental and is subject to
21 | * > change, or removal, at any time!
22 | * > <hr>
23 | *
24 | * Sample usage:
25 | *
26 | * var driver = new webdriver.Builder().build();
27 | * driver.get('http://www.google.com');
28 | *
29 | * assert(driver.getTitle()).equalTo('Google');
30 | */
31 |
32 | var base = require('../_base'),
33 | assert = base.require('webdriver.testing.assert');
34 |
35 |
36 | // PUBLIC API
37 |
38 |
39 | /**
40 | * Creates a new assertion.
41 | * @param {*} value The value to perform an assertion on.
42 | * @return {!webdriver.testing.Assertion} The new assertion.
43 | */
44 | module.exports = function(value) {
45 | return assert(value);
46 | };
47 |
48 |
49 | /**
50 | * Registers a new assertion to expose from the
51 | * {@link webdriver.testing.Assertion} prototype.
52 | * @param {string} name The assertion name.
53 | * @param {(function(new: goog.labs.testing.Matcher, *)|
54 | * {matches: function(*): boolean,
55 | * describe: function(): string})} matcherTemplate Either the
56 | * matcher constructor to use, or an object literal defining a matcher.
57 | */
58 | module.exports.register = assert.register;