Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation to Chai version 2.2.0 #84

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/codex.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"tweeturl": "http://chaijs.com",
"tweetvia": "jakeluer",
"tweetrelated": "jakeluer",
"version": "2.1.0",
"version": "2.2.0",
"hasdownloads": false,
"description": "Chai is a BDD / TDD assertion library for [node](http://nodejs.org) and the browser that can be delightfully paired with any javascript testing framework."
},
Expand Down
6 changes: 3 additions & 3 deletions out/api/assert/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<script src="/public/js/main.js?2.2.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
24 changes: 19 additions & 5 deletions out/api/bdd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<script src="/public/js/main.js?2.2.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down Expand Up @@ -120,6 +120,10 @@ <h2 id="api-reference">API Reference</h2>
<pre><code>expect(foo).to.deep.equal({ bar: <span class="string">'baz'</span> });
expect({ foo: { bar: { baz: <span class="string">'quux'</span> } } })
.to.have.deep.property(<span class="string">'foo.bar.baz'</span>, <span class="string">'quux'</span>);</code></pre>
<p><code>.deep.property</code> special characters can be escaped
by adding two slashes before the <code>.</code> or <code>[]</code>.</p>
<pre><code><span class="keyword">var</span> deepCss = { <span class="string">'.link'</span>: { <span class="string">'[target]'</span>: <span class="number">42</span> }};
expect(deepCss).to.have.deep.property(<span class="string">'\\.link.\\[target\\]'</span>, <span class="number">42</span>);</code></pre>
</div>
</div>
<div id="any-section" class="segment">
Expand Down Expand Up @@ -218,7 +222,7 @@ <h2 id="api-reference">API Reference</h2>
</ul>
<div class="description"><p>Asserts that the target is <code>null</code>.</p>
<pre><code>expect(<span class="literal">null</span>).to.be.<span class="literal">null</span>;
expect(undefined).not.to.be.<span class="literal">null</span>;</code></pre>
expect(undefined).to.not.be.<span class="literal">null</span>;</code></pre>
</div>
</div>
<div id="undefined-section" class="segment">
Expand Down Expand Up @@ -251,7 +255,7 @@ <h2 id="api-reference">API Reference</h2>
</div>
<ul class="tags">
</ul>
<div class="description"><p>Asserts that the target&#39;s length is <code>0</code>. For arrays, it checks
<div class="description"><p>Asserts that the target&#39;s length is <code>0</code>. For arrays and strings, it checks
the <code>length</code> property. For objects, it gets the count of
enumerable keys.</p>
<pre><code>expect([]).to.be.empty;
Expand Down Expand Up @@ -449,6 +453,16 @@ <h2 id="api-reference">API Reference</h2>
.that.is.an(<span class="string">'array'</span>)
.<span class="keyword">with</span>.deep.property(<span class="string">'[2]'</span>)
.that.deep.equals({ tea: <span class="string">'konacha'</span> });</code></pre>
<p>Note that dots and bracket in <code>name</code> must be backslash-escaped when
the <code>deep</code> flag is set, while they must NOT be escaped when the <code>deep</code>
flag is not set.</p>
<pre><code><span class="comment">// simple referencing</span>
<span class="keyword">var</span> css = { <span class="string">'.link[target]'</span>: <span class="number">42</span> };
expect(css).to.have.property(<span class="string">'.link[target]'</span>, <span class="number">42</span>);

<span class="comment">// deep referencing</span>
<span class="keyword">var</span> deepCss = { <span class="string">'.link'</span>: { <span class="string">'[target]'</span>: <span class="number">42</span> }};
expect(deepCss).to.have.deep.property(<span class="string">'\\.link.\\[target\\]'</span>, <span class="number">42</span>);</code></pre>
</div>
</div>
<div id="ownProperty-section" class="segment">
Expand Down
6 changes: 3 additions & 3 deletions out/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<script src="/public/js/main.js?2.2.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
6 changes: 3 additions & 3 deletions out/api/plugins/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<script src="/public/js/main.js?2.2.0"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
6 changes: 3 additions & 3 deletions out/api/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/tests/mocha.js"></script>
<script>mocha.setup('tdd');</script>
<script src="/chai.js"></script>
Expand Down Expand Up @@ -40,8 +40,8 @@
};

</script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
83 changes: 66 additions & 17 deletions out/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ var used = []
* Chai version
*/

exports.version = '2.1.0';
exports.version = '2.2.0';

/*!
* Assertion Error
Expand Down Expand Up @@ -852,10 +852,11 @@ module.exports = function (_chai, util) {
*
* @name assert
* @param {Philosophical} expression to be tested
* @param {String or Function} message or function that returns message to display if fails
* @param {String or Function} message or function that returns message to display if expression fails
* @param {String or Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
* @param {Mixed} expected value (remember to check for negation)
* @param {Mixed} actual (optional) will default to `this.obj`
* @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
* @api private
*/

Expand Down Expand Up @@ -932,11 +933,16 @@ module.exports = {
* ### config.truncateThreshold
*
* User configurable property, sets length threshold for actual and
* expected values in assertion errors. If this threshold is exceeded,
* the value is truncated.
* expected values in assertion errors. If this threshold is exceeded, for
* example for large data structures, the value is replaced with something
* like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
*
* Set it to zero if you want to disable truncating altogether.
*
* This is especially userful when doing assertions on arrays: having this
* set to a reasonable large value makes the failure messages readily
* inspectable.
*
* chai.config.truncateThreshold = 0; // disable truncating
*
* @param {Number}
Expand Down Expand Up @@ -1027,6 +1033,12 @@ module.exports = function (chai, _) {
* expect({ foo: { bar: { baz: 'quux' } } })
* .to.have.deep.property('foo.bar.baz', 'quux');
*
* `.deep.property` special characters can be escaped
* by adding two slashes before the `.` or `[]`.
*
* var deepCss = { '.link': { '[target]': 42 }};
* expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42);
*
* @name deep
* @api public
*/
Expand Down Expand Up @@ -1300,7 +1312,7 @@ module.exports = function (chai, _) {
/**
* ### .empty
*
* Asserts that the target's length is `0`. For arrays, it checks
* Asserts that the target's length is `0`. For arrays and strings, it checks
* the `length` property. For objects, it gets the count of
* enumerable keys.
*
Expand Down Expand Up @@ -1713,7 +1725,7 @@ module.exports = function (chai, _) {
* green: { tea: 'matcha' }
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
* };

*
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
Expand Down Expand Up @@ -1745,6 +1757,18 @@ module.exports = function (chai, _) {
* .with.deep.property('[2]')
* .that.deep.equals({ tea: 'konacha' });
*
* Note that dots and bracket in `name` must be backslash-escaped when
* the `deep` flag is set, while they must NOT be escaped when the `deep`
* flag is not set.
*
* // simple referencing
* var css = { '.link[target]': 42 };
* expect(css).to.have.property('.link[target]', 42);
*
* // deep referencing
* var deepCss = { '.link': { '[target]': 42 }};
* expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42);
*
* @name property
* @alias deep.property
* @param {String} name
Expand Down Expand Up @@ -3494,10 +3518,36 @@ module.exports = function (chai, util) {
*/

assert.operator = function (val, operator, val2, msg) {
if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
throw new Error('Invalid operator "' + operator + '"');
var ok;
switch(operator) {
case '==':
ok = val == val2;
break;
case '===':
ok = val === val2;
break;
case '>':
ok = val > val2;
break;
case '>=':
ok = val >= val2;
break;
case '<':
ok = val < val2;
break;
case '<=':
ok = val <= val2;
break;
case '!=':
ok = val != val2;
break;
case '!==':
ok = val !== val2;
break;
default:
throw new Error('Invalid operator "' + operator + '"');
}
var test = new Assertion(eval(val + operator + val2), msg);
var test = new Assertion(ok, msg);
test.assert(
true === flag(test, 'object')
, 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
Expand Down Expand Up @@ -3778,10 +3828,8 @@ module.exports = function (chai, util) {
function loadShould () {
// explicitly define this method as function as to have it's name to include as `ssfi`
function shouldGetter() {
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this), null, shouldGetter);
} else if (this instanceof Boolean) {
return new Assertion(this == true, null, shouldGetter);
if (this instanceof String || this instanceof Number || this instanceof Boolean ) {
return new Assertion(this.valueOf(), null, shouldGetter);
}
return new Assertion(this, null, shouldGetter);
}
Expand Down Expand Up @@ -4321,7 +4369,7 @@ module.exports = function getPathInfo(path, obj) {
last = parsed[parsed.length - 1];

var info = {
parent: _getPathValue(parsed, obj, parsed.length - 1),
parent: parsed.length > 1 ? _getPathValue(parsed, obj, parsed.length - 1) : obj,
name: last.p || last.i,
value: _getPathValue(parsed, obj),
};
Expand All @@ -4343,20 +4391,21 @@ module.exports = function getPathInfo(path, obj) {
*
* * Can be as near infinitely deep and nested
* * Arrays are also valid using the formal `myobject.document[3].property`.
* * Literal dots and brackets (not delimiter) must be backslash-escaped.
*
* @param {String} path
* @returns {Object} parsed
* @api private
*/

function parsePath (path) {
var str = path.replace(/\[/g, '.[')
var str = path.replace(/([^\\])\[/g, '$1.[')
, parts = str.match(/(\\\.|[^.]+?)+/g);
return parts.map(function (value) {
var re = /\[(\d+)\]$/
var re = /^\[(\d+)\]$/
, mArr = re.exec(value);
if (mArr) return { i: parseFloat(mArr[1]) };
else return { p: value };
else return { p: value.replace(/\\([.\[\]])/g, '$1') };
});
}

Expand Down
6 changes: 3 additions & 3 deletions out/guide/helpers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/guide.js"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
6 changes: 3 additions & 3 deletions out/guide/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/guide.js"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
6 changes: 3 additions & 3 deletions out/guide/installation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/guide.js"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
8 changes: 4 additions & 4 deletions out/guide/plugins/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/guide.js"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down Expand Up @@ -233,4 +233,4 @@ <h3 class="fancy"><a href="#">Chai Assertion Library</a></h3>
</section>
</footer>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions out/guide/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/public/js/jquery-mousewheel.js"></script>
<script src="/public/js/antiscroll.js"></script>
<script src="/public/js/main.js?2.1.0"></script>
<script src="/public/js/main.js?2.2.0"></script>
<script src="/public/js/guide.js"></script>
<link rel="stylesheet" href="/public/css/antiscroll.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.1.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/antiscroll.css?2.2.0" type="text/css" media="all">
<link rel="stylesheet" href="/public/css/main.css?2.2.0" type="text/css" media="all">
<script type="text/javascript">
var mpq = [];
mpq.push(["init", "d5e84615dbd02dbc359b0f76d0ed7cf5"]);
Expand Down
Loading