forked from chaijs/chai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug when asserting some valid ES6 keys
- Resolution of chaijs#674 - Add compareByInspect util for use with assertKeys sorts - Add Symbol support to the inspect utility - Add tests to utilities, should, expect, and assert
- Loading branch information
Showing
8 changed files
with
239 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*! | ||
* Chai - compareByInspect utility | ||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com> | ||
* MIT Licensed | ||
*/ | ||
|
||
/*! | ||
* Module dependancies | ||
*/ | ||
|
||
var inspect = require('./inspect'); | ||
|
||
/** | ||
* ### .compareByInspect (mixed, mixed) | ||
* | ||
* To be used as a compareFunction with Array.prototype.sort. Compares elements | ||
* using inspect instead of default behavior of using toString so that Symbols | ||
* and objects with irregular/missing toString can still be sorted without a | ||
* TypeError. | ||
* | ||
* @param {Mixed} first element to compare | ||
* @param {Mixed} second element to compare | ||
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1 | ||
* @name compareByInspect | ||
* @namespace Utils | ||
* @api public | ||
*/ | ||
|
||
module.exports = function (a, b) { | ||
return inspect(a) < inspect(b) ? -1 : 1; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters