Skip to content

Commit

Permalink
Release 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalparadox committed Sep 29, 2014
1 parent 834fd5b commit 15eab03
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 32 deletions.
22 changes: 22 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@

1.9.2 / 2014-09-29
==================

* Merge pull request #268 from charlierudolph/cr-lazyMessages
* Merge pull request #269 from charlierudolph/cr-codeCleanup
* Merge pull request #277 from charlierudolph/fix-doc
* Merge pull request #279 from mohayonao/fix-closeTo
* Merge pull request #292 from boneskull/mocha
* resolves #255: upgrade mocha
* Merge pull request #289 from charlierudolph/cr-dryUpCode
* Dry up code
* Merge pull request #275 from DrRataplan/master
* assert: .closeTo() verify value's type before assertion
* Rewrite pretty-printing HTML elements to prevent throwing internal errors Fixes errors occuring when using a non-native DOM implementation
* Fix assert documentation
* Remove unused argument
* Allow messages to be functions
* Merge pull request #267 from shinnn/master
* Use SVG badge
* Merge pull request #264 from cjthompson/keys_diff
* Show diff for keys assertion

1.9.1 / 2014-03-19
==================

Expand Down
25 changes: 25 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Release Notes

## 1.9.2 / 2014-09-29

The following changes are required if you are upgrading from the previous version:

- **Users:**
- No changes required
- **Plugin Developers:**
- No changes required
- **Core Contributors:**
- Refresh `node_modules` folder for updated dependencies.

### Community Contributions

- [#264](https://github.com/chaijs/chai/pull/264) Show diff for keys assertions [@cjthompson](https://github.com/cjthompson)
- [#267](https://github.com/chaijs/chai/pull/267) Use SVG badges [@shinnn](https://github.com/shinnn)
- [#268](https://github.com/chaijs/chai/pull/268) Allow messages to be functions (sinon-compat) [@charlierudolph](https://github.com/charlierudolph)
- [#269](https://github.com/chaijs/chai/pull/269) Remove unused argument for #lengthOf [@charlierudolph](https://github.com/charlierudolph)
- [#275](https://github.com/chaijs/chai/pull/275) Rewrite pretty-printing HTML elements to prevent throwing internal errors [@DrRataplan](https://github.com/DrRataplan)
- [#277](https://github.com/chaijs/chai/pull/277) Fix assert documentation for #sameMembers [@charlierudolph](https://github.com/charlierudolph)
- [#279](https://github.com/chaijs/chai/pull/279) closeTo should check value's type before assertion [@mohayonao](https://github.com/mohayonao)
- [#289](https://github.com/chaijs/chai/pull/289) satisfy is called twice [@charlierudolph](https://github.com/charlierudolph)
- [#292](https://github.com/chaijs/chai/pull/292) resolve conflicts with node-webkit and global usage [@boneskull](https://github.com/boneskull)

Thank you to all who took time to contribute!

## 1.9.1 / 2014-03-19

The following changes are required if you are upgrading from the previous version:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chai"
, "version": "1.9.1"
, "version": "1.9.2"
, "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic."
, "license": "MIT"
, "keywords": [
Expand Down
78 changes: 50 additions & 28 deletions chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ var used = []
* Chai version
*/

exports.version = '1.9.1';
exports.version = '1.9.2';

/*!
* Assertion Error
Expand Down Expand Up @@ -903,8 +903,8 @@ module.exports = function (_chai, util) {
*
* @name assert
* @param {Philosophical} expression to be tested
* @param {String} message to display if fails
* @param {String} negatedMessage to display if negated expression fails
* @param {String or Function} message or function that returns message to display if 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`
* @api private
Expand Down Expand Up @@ -1872,7 +1872,7 @@ module.exports = function (chai, _) {
}

Assertion.addChainableMethod('length', assertLength, assertLengthChain);
Assertion.addMethod('lengthOf', assertLength, assertLengthChain);
Assertion.addMethod('lengthOf', assertLength);

/**
* ### .match(regexp)
Expand Down Expand Up @@ -1951,6 +1951,7 @@ module.exports = function (chai, _) {
if (!keys.length) throw new Error('keys required');

var actual = Object.keys(obj)
, expected = keys
, len = keys.length;

// Inclusion
Expand Down Expand Up @@ -1985,6 +1986,9 @@ module.exports = function (chai, _) {
ok
, 'expected #{this} to ' + str
, 'expected #{this} to not ' + str
, expected.sort()
, actual.sort()
, true
);
}

Expand Down Expand Up @@ -2220,12 +2224,13 @@ module.exports = function (chai, _) {
Assertion.addMethod('satisfy', function (matcher, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
var result = matcher(obj);
this.assert(
matcher(obj)
result
, 'expected #{this} to satisfy ' + _.objDisplay(matcher)
, 'expected #{this} to not satisfy' + _.objDisplay(matcher)
, this.negate ? false : true
, matcher(obj)
, result
);
});

Expand All @@ -2246,6 +2251,12 @@ module.exports = function (chai, _) {
Assertion.addMethod('closeTo', function (expected, delta, msg) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');

new Assertion(obj, msg).is.a('number');
if (_.type(expected) !== 'number' || _.type(delta) !== 'number') {
throw new Error('the arguments to closeTo must be numbers');
}

this.assert(
Math.abs(obj - expected) <= delta
, 'expected #{this} to be close to ' + expected + ' +/- ' + delta
Expand Down Expand Up @@ -3324,8 +3335,8 @@ module.exports = function (chai, util) {
* assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
*
* @name sameMembers
* @param {Array} superset
* @param {Array} subset
* @param {Array} set1
* @param {Array} set2
* @param {String} message
* @api public
*/
Expand Down Expand Up @@ -3799,6 +3810,7 @@ module.exports = function (obj, args) {
, msg = negate ? args[2] : args[1]
, flagMsg = flag(obj, 'message');

if(typeof msg === "function") msg = msg();
msg = msg || '';
msg = msg
.replace(/#{this}/g, objDisplay(val))
Expand Down Expand Up @@ -4122,24 +4134,6 @@ function inspect(obj, showHidden, depth, colors) {
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
}

// https://gist.github.com/1044128/
var getOuterHTML = function(element) {
if ('outerHTML' in element) return element.outerHTML;
var ns = "http://www.w3.org/1999/xhtml";
var container = document.createElementNS(ns, '_');
var elemProto = (window.HTMLElement || window.Element).prototype;
var xmlSerializer = new XMLSerializer();
var html;
if (document.xmlVersion) {
return xmlSerializer.serializeToString(element);
} else {
container.appendChild(element.cloneNode(false));
html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
container.innerHTML = '';
return html;
}
};

// Returns true if object is a DOM element.
var isDOMElement = function (object) {
if (typeof HTMLElement === 'object') {
Expand Down Expand Up @@ -4173,9 +4167,37 @@ function formatValue(ctx, value, recurseTimes) {
return primitive;
}

// If it's DOM elem, get outer HTML.
// If this is a DOM element, try to get the outer HTML.
if (isDOMElement(value)) {
return getOuterHTML(value);
if ('outerHTML' in value) {
return value.outerHTML;
// This value does not have an outerHTML attribute,
// it could still be an XML element
} else {
// Attempt to serialize it
try {
if (document.xmlVersion) {
var xmlSerializer = new XMLSerializer();
return xmlSerializer.serializeToString(value);
} else {
// Firefox 11- do not support outerHTML
// It does, however, support innerHTML
// Use the following to render the element
var ns = "http://www.w3.org/1999/xhtml";
var container = document.createElementNS(ns, '_');

container.appendChild(value.cloneNode(false));
html = container.innerHTML
.replace('><', '>' + value.innerHTML + '<');
container.innerHTML = '';
return html;
}
} catch (err) {
// This could be a non-native DOM implementation,
// continue with the normal flow:
// printing the element as if it is an object.
}
}
}

// Look up the keys of the object.
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chai"
, "repo": "chaijs/chai"
, "version": "1.9.1"
, "version": "1.9.2"
, "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic."
, "license": "MIT"
, "keywords": [
Expand Down
2 changes: 1 addition & 1 deletion lib/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var used = []
* Chai version
*/

exports.version = '1.9.1';
exports.version = '1.9.2';

/*!
* Assertion Error
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Veselin Todorov <[email protected]>",
"John Firebaugh <[email protected]>"
],
"version": "1.9.1",
"version": "1.9.2",
"repository": {
"type": "git",
"url": "https://github.com/chaijs/chai"
Expand Down

0 comments on commit 15eab03

Please sign in to comment.