Socket
Socket
Sign inDemoInstall

chai

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai - npm Package Compare versions

Comparing version 1.9.0 to 1.9.1

lib/chai/config.js

2

bower.json
{
"name": "chai"
, "version": "1.9.0"
, "version": "1.9.1"
, "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic."

@@ -5,0 +5,0 @@ , "license": "MIT"

@@ -34,3 +34,3 @@ # Chai Contribution Guidelines

The issue tracker is the preferred channel for [bug reports](#bugs),
[features requests](#features) and [submitting pull
[feature requests](#features) and [submitting pull
requests](#pull-requests), but please respect the following restrictions:

@@ -79,3 +79,3 @@

Furthermore, since Chai.js has a [robust plugin API](http://chaijs.com/guide/plugins/), we encourage you to publish **new Assertions** as plugins. If your feature is an enhancement to an **existing Assertion**, please propose your changes as an issue prior to opening a pull request. If the core Chai.js contributors feel your plugin would be better suited as a core assertion, they will invite you to open a PR in [chaijs/chai](https//github.com/chaijs/chai).
Furthermore, since Chai.js has a [robust plugin API](http://chaijs.com/guide/plugins/), we encourage you to publish **new Assertions** as plugins. If your feature is an enhancement to an **existing Assertion**, please propose your changes as an issue prior to opening a pull request. If the core Chai.js contributors feel your plugin would be better suited as a core assertion, they will invite you to open a PR in [chaijs/chai](https://github.com/chaijs/chai).

@@ -95,3 +95,3 @@ <a name="pull-requests"></a>

Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Please review the [Chai.js Codeing Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide).
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Please review the [Chai.js Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide).

@@ -98,0 +98,0 @@ Follow this process if you'd like your work considered for inclusion in the project:

1.9.1 / 2014-03-19
==================
* deps update
* util: [getActual] select actual logic now allows undefined for actual. Closes #183
* docs: [config] make public, express param type
* Merge pull request #251 from romario333/threshold3
* Fix issue #166 - configurable threshold in objDisplay.
* Move configuration options to config.js.
* Merge pull request #233 from Empeeric/master
* Merge pull request #244 from leider/fix_for_contains
* Merge pull request #247 from didoarellano/typo-fixes
* Fix typos
* Merge pull request #245 from lfac-pt/patch-1
* Update `exports.version` to 1.9.0
* aborting loop on finding
* declaring variable only once
* additional test finds incomplete implementation
* simplified code
* fixing #239 (without changing chai.js)
* ssfi as it should be
* Merge pull request #228 from duncanbeevers/deep_members
* Deep equality check for collection membership
1.9.0 / 2014-01-29

@@ -3,0 +27,0 @@ ==================

@@ -14,3 +14,3 @@ /*!

exports.version = '1.8.1';
exports.version = '1.9.1';

@@ -49,2 +49,9 @@ /*!

/*!
* Configuration
*/
var config = require('./chai/config');
exports.config = config;
/*!
* Primary `Assertion` prototype

@@ -51,0 +58,0 @@ */

@@ -8,2 +8,4 @@ /*!

var config = require('./config');
module.exports = function (_chai, util) {

@@ -37,30 +39,24 @@ /*!

/*!
* ### Assertion.includeStack
*
* User configurable property, influences whether stack trace
* is included in Assertion error message. Default of false
* suppresses stack trace in the error message
*
* Assertion.includeStack = true; // enable stack on error
*
* @api public
*/
Object.defineProperty(Assertion, 'includeStack', {
get: function() {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
return config.includeStack;
},
set: function(value) {
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
config.includeStack = value;
}
});
Assertion.includeStack = false;
Object.defineProperty(Assertion, 'showDiff', {
get: function() {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
return config.showDiff;
},
set: function(value) {
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
config.showDiff = value;
}
});
/*!
* ### Assertion.showDiff
*
* User configurable property, influences whether or not
* the `showDiff` flag should be included in the thrown
* AssertionErrors. `false` will always be `false`; `true`
* will be true when the assertion has requested a diff
* be shown.
*
* @api public
*/
Assertion.showDiff = true;
Assertion.addProperty = function (name, fn) {

@@ -107,3 +103,3 @@ util.addProperty(this.prototype, name, fn);

if (true !== showDiff) showDiff = false;
if (true !== Assertion.showDiff) showDiff = false;
if (true !== config.showDiff) showDiff = false;

@@ -117,3 +113,3 @@ if (!ok) {

, showDiff: showDiff
}, (Assertion.includeStack) ? this.assert : flag(this, 'ssfi'));
}, (config.includeStack) ? this.assert : flag(this, 'ssfi'));
}

@@ -120,0 +116,0 @@ };

@@ -18,3 +18,3 @@ /*!

* improve the readability of your assertions. They
* do not provide an testing capability unless they
* do not provide testing capabilities unless they
* have been overwritten by a plugin.

@@ -151,4 +151,11 @@ *

var obj = flag(this, 'object');
if (_.type(val) === 'object') {
var expected = false;
if (_.type(obj) === 'array' && _.type(val) === 'object') {
for (var i in obj) {
if (_.eql(obj[i], val)) {
expected = true;
break;
}
}
} else if (_.type(val) === 'object') {
if (!flag(this, 'negate')) {

@@ -160,5 +167,5 @@ for (var k in val) new Assertion(obj).property(k, val[k]);

for (var k in val) subset[k] = obj[k]
var expected = _.eql(subset, val);
expected = _.eql(subset, val);
} else {
var expected = obj && ~obj.indexOf(val)
expected = obj && ~obj.indexOf(val)
}

@@ -1251,5 +1258,9 @@ this.assert(

function isSubsetOf(subset, superset) {
function isSubsetOf(subset, superset, cmp) {
return subset.every(function(elem) {
return superset.indexOf(elem) !== -1;
if (!cmp) return superset.indexOf(elem) !== -1;
return superset.some(function(elem2) {
return cmp(elem, elem2);
});
})

@@ -1262,3 +1273,5 @@ }

* Asserts that the target is a superset of `set`,
* or that the target and `set` have the same members.
* or that the target and `set` have the same strictly-equal (===) members.
* Alternately, if the `deep` flag is set, set members are compared for deep
* equality.
*

@@ -1271,2 +1284,4 @@ * expect([1, 2, 3]).to.include.members([3, 2]);

*
* expect([{ id: 1 }]).to.deep.include.members([{ id: 1 }]);
*
* @name members

@@ -1285,5 +1300,7 @@ * @param {Array} set

var cmp = flag(this, 'deep') ? _.eql : undefined;
if (flag(this, 'contains')) {
return this.assert(
isSubsetOf(subset, obj)
isSubsetOf(subset, obj, cmp)
, 'expected #{this} to be a superset of #{act}'

@@ -1297,3 +1314,3 @@ , 'expected #{this} to not be a superset of #{act}'

this.assert(
isSubsetOf(obj, subset) && isSubsetOf(subset, obj)
isSubsetOf(obj, subset, cmp) && isSubsetOf(subset, obj, cmp)
, 'expected #{this} to have the same members as #{act}'

@@ -1300,0 +1317,0 @@ , 'expected #{this} to not have the same members as #{act}'

@@ -36,3 +36,3 @@ /*!

var assert = chai.assert = function (express, errmsg) {
var test = new Assertion(null);
var test = new Assertion(null, null, chai.assert);
test.assert(

@@ -118,3 +118,3 @@ express

assert.equal = function (act, exp, msg) {
var test = new Assertion(act, msg);
var test = new Assertion(act, msg, assert.equal);

@@ -145,3 +145,3 @@ test.assert(

assert.notEqual = function (act, exp, msg) {
var test = new Assertion(act, msg);
var test = new Assertion(act, msg, assert.notEqual);

@@ -397,4 +397,4 @@ test.assert(

* var selection = 'chai'
* assert.isObject(selection, 'tea selection is not an object');
* assert.isObject(null, 'null is not an object');
* assert.isNotObject(selection, 'tea selection is not an object');
* assert.isNotObject(null, 'null is not an object');
*

@@ -663,3 +663,3 @@ * @name isNotObject

assert.include = function (exp, inc, msg) {
new Assertion(exp, msg).include(inc);
new Assertion(exp, msg, assert.include).include(inc);
};

@@ -684,3 +684,3 @@

assert.notInclude = function (exp, inc, msg) {
new Assertion(exp, msg).not.include(inc);
new Assertion(exp, msg, assert.notInclude).not.include(inc);
};

@@ -687,0 +687,0 @@

@@ -11,27 +11,29 @@ /*!

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);
}
return new Assertion(this, null, shouldGetter);
}
function shouldSetter(value) {
// See https://github.com/chaijs/chai/issues/86: this makes
// `whatever.should = someValue` actually set `someValue`, which is
// especially useful for `global.should = require('chai').should()`.
//
// Note that we have to use [[DefineProperty]] instead of [[Put]]
// since otherwise we would trigger this very setter!
Object.defineProperty(this, 'should', {
value: value,
enumerable: true,
configurable: true,
writable: true
});
}
// modify Object.prototype to have `should`
Object.defineProperty(Object.prototype, 'should',
{
set: function (value) {
// See https://github.com/chaijs/chai/issues/86: this makes
// `whatever.should = someValue` actually set `someValue`, which is
// especially useful for `global.should = require('chai').should()`.
//
// Note that we have to use [[DefineProperty]] instead of [[Put]]
// since otherwise we would trigger this very setter!
Object.defineProperty(this, 'should', {
value: value,
enumerable: true,
configurable: true,
writable: true
});
}
, get: function(){
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this));
} else if (this instanceof Boolean) {
return new Assertion(this == true);
}
return new Assertion(this);
}
Object.defineProperty(Object.prototype, 'should', {
set: shouldSetter
, get: shouldGetter
, configurable: true

@@ -38,0 +40,0 @@ });

@@ -12,2 +12,4 @@ /*!

var transferFlags = require('./transferFlags');
var flag = require('./flag');
var config = require('../config');

@@ -78,3 +80,6 @@ /*!

var assert = function () {
var assert = function assert() {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', assert);
var result = chainableBehavior.method.apply(this, arguments);

@@ -81,0 +86,0 @@ return result === undefined ? this : result;

@@ -7,2 +7,4 @@ /*!

var config = require('../config');
/**

@@ -32,5 +34,9 @@ * ### .addMethod (ctx, name, method)

*/
var flag = require('./flag');
module.exports = function (ctx, name, method) {
ctx[name] = function () {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', ctx[name]);
var result = method.apply(this, arguments);

@@ -37,0 +43,0 @@ return result === undefined ? this : result;

@@ -17,4 +17,3 @@ /*!

module.exports = function (obj, args) {
var actual = args[4];
return 'undefined' !== typeof actual ? actual : obj._obj;
return args.length > 4 ? args[4] : obj._obj;
};

@@ -12,2 +12,3 @@ /*!

var inspect = require('./inspect');
var config = require('../config');

@@ -30,3 +31,3 @@ /**

if (str.length >= 40) {
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
if (type === '[object Function]') {

@@ -33,0 +34,0 @@ return !obj.name || obj.name === ''

@@ -14,3 +14,3 @@ {

],
"version": "1.9.0",
"version": "1.9.1",
"repository": {

@@ -36,9 +36,9 @@ "type": "git",

"component": "*"
, "karma": "0.11.12"
, "karma": "0.12.x"
, "karma-mocha": "*"
, "karma-sauce-launcher": "0.2.0"
, "karma-sauce-launcher": "0.2.x"
, "karma-phantomjs-launcher": "0.1.1"
, "mocha": "1.8.2"
, "istanbul": "~0.1.44"
, "mocha": "1.17.x"
, "istanbul": "0.2.x"
}
}

@@ -12,2 +12,10 @@ [![Chai Documentation](http://chaijs.com/public/img/chai-logo.png)](http://chaijs.com)

### Plugins
Chai offers a robust Plugin architecture for extending Chai's assertions and interfaces.
- Need a plugin? View the [official plugin list](http://chaijs.com/plugins).
- Have a plugin and want it listed? Open a Pull Request at [chaijs/chai-docs:plugin.js](https://github.com/chaijs/chai-docs/blob/master/plugins.js#L1-L12).
- Want to build a plugin? Read the [plugin api documentation](http://chaijs.com/guide/plugins/).
### Related Projects

@@ -21,10 +29,10 @@

project : chai
repo age : 2 years, 2 months ago
commits : 735
active : 158 days
files : 56
repo age : 2 years, 3 months ago
commits : 756
active : 170 days
files : 57
authors :
532 Jake Luer 72.4%
79 Veselin Todorov 10.7%
43 Domenic Denicola 5.9%
540 Jake Luer 71.4%
79 Veselin Todorov 10.4%
43 Domenic Denicola 5.7%
6 Ruben Verborgh 0.8%

@@ -35,2 +43,3 @@ 5 George Kats 0.7%

5 Scott Nonnenberg 0.7%
5 leider 0.7%
4 John Firebaugh 0.5%

@@ -41,9 +50,11 @@ 4 Max Edmands 0.5%

3 Andrei Neculau 0.4%
3 Duncan Beevers 0.4%
3 Jake Rosoman 0.4%
3 Jeff Barczewski 0.4%
3 Ryunosuke SATO 0.4%
3 Veselin 0.4%
2 Bartvds 0.3%
2 Duncan Beevers 0.3%
2 Edwin Shao 0.3%
2 Jakub Nešetřil 0.3%
2 Roman Masek 0.3%
2 Teddy Cross 0.3%

@@ -56,8 +67,10 @@ 1 Anand Patil 0.1%

1 DD 0.1%
1 Dido Arellano 0.1%
1 Jeff Welch 0.1%
1 Kilian Ciuffolo 0.1%
1 Luís Cardoso 0.1%
1 Niklas Närhinen 0.1%
1 Paul Miller 0.1%
1 Refael Ackermann 0.1%
1 Sasha Koss 0.1%
1 Veselin 0.1%
1 Victor Costan 0.1%

@@ -64,0 +77,0 @@ 1 Vinay Pulim 0.1%

# Release Notes
## 1.9.1 / 2014-03-19
The following changes are required if you are upgrading from the previous version:
- **Users:**
- Migrate configuration options to new interface. (see notes)
- **Plugin Developers:**
- No changes required
- **Core Contributors:**
- Refresh `node_modules` folder for updated dependencies.
### Configuration
There have been requests for changes and additions to the configuration mechanisms
and their impact in the Chai architecture. As such, we have decoupled the
configuration from the `Assertion` constructor. This not only allows for centralized
configuration, but will allow us to shift the responsibility from the `Assertion`
constructor to the `assert` interface in future releases.
These changes have been implemented in a non-breaking way, but a depretiation
warning will be presented to users until they migrate. The old config method will
be removed in either `v1.11.0` or `v2.0.0`, whichever comes first.
#### Quick Migration
```js
// change this:
chai.Assertion.includeStack = true;
chai.Assertion.showDiff = false;
// ... to this:
chai.config.includeStack = true;
chai.config.showDiff = false;
```
#### All Config Options
##### config.includeStack
- **@param** _{Boolean}_
- **@default** `false`
User configurable property, influences whether stack trace is included in
Assertion error message. Default of `false` suppresses stack trace in the error
message.
##### config.showDiff
- **@param** _{Boolean}_
- **@default** `true`
User configurable property, influences whether or not the `showDiff` flag
should be included in the thrown AssertionErrors. `false` will always be `false`;
`true` will be true when the assertion has requested a diff be shown.
##### config.truncateThreshold **(NEW)**
- **@param** _{Number}_
- **@default** `40`
User configurable property, sets length threshold for actual and expected values
in assertion errors. If this threshold is exceeded, the value is truncated.
Set it to zero if you want to disable truncating altogether.
```js
chai.config.truncateThreshold = 0; // disable truncating
```
### Community Contributions
- [#228](https://github.com/chaijs/chai/pull/228) Deep equality check for memebers. [@duncanbeevers](https://github.com/duncanbeevers)
- [#247](https://github.com/chaijs/chai/pull/247) Proofreading. [@didorellano](https://github.com/didoarellano)
- [#244](https://github.com/chaijs/chai/pull/244) Fix `contain`/`include` 1.9.0 regression. [@leider](https://github.com/leider)
- [#233](https://github.com/chaijs/chai/pull/233) Improvements to `ssfi` for `assert` interface. [@refack](https://github.com/refack)
- [#251](https://github.com/chaijs/chai/pull/251) New config option: object display threshold. [@romario333](https://github.com/romario333)
Thank you to all who took time to contribute!
### Other Bug Fixes
- [#183](https://github.com/chaijs/chai/issues/183) Allow `undefined` for actual. (internal api)
- Update Karam(+plugins)/Istanbul to most recent versions.
## 1.9.0 / 2014-01-29

@@ -4,0 +88,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc