Large diffs are not rendered by default.

@@ -0,0 +1,83 @@
[![Chai Documentation](http://chaijs.com/public/img/chai-logo.png)](http://chaijs.com)

[![license:mit](https://img.shields.io/badge/license-mit-green.svg?style=flat-square)](#license)<br>
[![tag:?](https://img.shields.io/github/tag/chaijs/chai.svg?style=flat-square)](https://github.com/chaijs/chai/releases)
[![build:?](https://img.shields.io/travis/chaijs/chai/master.svg?style=flat-square)](https://travis-ci.org/chaijs/chai)
[![coverage:?](https://img.shields.io/coveralls/chaijs/chai/master.svg?style=flat-square)](https://coveralls.io/r/chaijs/chai)<br>
[![npm:](https://img.shields.io/npm/v/chai.svg?style=flat-square)](https://www.npmjs.com/packages/chai)
[![dependencies:?](https://img.shields.io/npm/dm/chai.svg?style=flat-square)](https://www.npmjs.com/packages/chai)
[![devDependencies:?](https://img.shields.io/david/chaijs/chai.svg?style=flat-square)](https://david-dm.org/chaijs/chai)

[![Selenium Test Status](https://saucelabs.com/browser-matrix/chaijs.svg)](https://saucelabs.com/u/chaijs)

[![Slack Status](https://chai-slack.herokuapp.com/badge.svg)]( https://chai-slack.herokuapp.com/)
[![Join the chat at https://gitter.im/chaijs/chai](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/chaijs/chai)

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.

For more information or to download plugins, view the [documentation](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

- [chaijs / assertion-error](https://github.com/chaijs/assertion-error): Custom `Error` constructor thrown upon an assertion failing.
- [chaijs / deep-eql](https://github.com/chaijs/deep-eql): Improved deep equality testing for Node.js and the browser.
- [chaijs / type-detect](https://github.com/chaijs/type-detect): Improved typeof detection for node.js and the browser.

### Contributing

Thank you very much for considering to contribute!

Here are a few issues other contributors frequently ran into when opening pull requests:

- Please do not commit changes to the `chai.js` build. We do it once per release.
- Before pushing your commits, please make sure you [rebase](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md#pull-requests) them.

We also strongly encourage you to read our detailed [contribution guidelines](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md).

### Contributors

Please see the full
[Contributors Graph](https://github.com/chaijs/chai/graphs/contributors) for our
list of contributors.

### Core Contributors

Feel free to reach out to any of the core contributors with your questions or
concerns. We will do our best to respond in a timely manner.

[![Jake Luer](https://avatars3.githubusercontent.com/u/58988?v=3&s=50)](https://github.com/logicalparadox)
[![Veselin Todorov](https://avatars3.githubusercontent.com/u/330048?v=3&s=50)](https://github.com/vesln)
[![Keith Cirkel](https://avatars3.githubusercontent.com/u/118266?v=3&s=50)](https://github.com/keithamus)

## License

(The MIT License)

Copyright (c) 2011-2015 Jake Luer <jake@alogicalparadox.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Large diffs are not rendered by default.

@@ -0,0 +1,26 @@
{
"name": "chai",
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
"license": "MIT",
"keywords": [
"test",
"assertion",
"assert",
"testing",
"chai"
],
"main": "chai.js",
"ignore": [
"build",
"components",
"lib",
"node_modules",
"support",
"test",
"index.js",
"Makefile",
".*"
],
"dependencies": {},
"devDependencies": {}
}

Large diffs are not rendered by default.

@@ -0,0 +1 @@
module.exports = require('./lib/chai');
@@ -0,0 +1,28 @@
module.exports = function(config) {
config.set({
frameworks: [ 'mocha' ]
, files: [
'chai.js'
, 'test/bootstrap/karma.js'
, 'test/*.js'
]
, reporters: [ 'progress' ]
, colors: true
, logLevel: config.LOG_INFO
, autoWatch: false
, browsers: [ 'PhantomJS' ]
, browserDisconnectTimeout: 10000
, browserDisconnectTolerance: 2
, browserNoActivityTimeout: 20000
, singleRun: true
});

switch (process.env.CHAI_TEST_ENV) {
case 'sauce':
require('./karma.sauce')(config);
break;
default:
// ...
break;
};
};
@@ -0,0 +1,41 @@
var version = require('./package.json').version;
var ts = new Date().getTime();

module.exports = function(config) {
var auth;

try {
auth = require('./test/auth/index');
} catch(ex) {
auth = {};
auth.SAUCE_USERNAME = process.env.SAUCE_USERNAME || null;
auth.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || null;
}

if (!auth.SAUCE_USERNAME || !auth.SAUCE_ACCESS_KEY) return;
if (process.env.SKIP_SAUCE) return;

var branch = process.env.TRAVIS_BRANCH || 'local'
var browserConfig = require('./sauce.browsers');
var browsers = Object.keys(browserConfig);
var tags = [ 'chaijs_' + version, auth.SAUCE_USERNAME + '@' + branch ];
var tunnel = process.env.TRAVIS_JOB_NUMBER || ts;

if (process.env.TRAVIS_JOB_NUMBER) {
tags.push('travis@' + process.env.TRAVIS_JOB_NUMBER);
}

config.browsers = config.browsers.concat(browsers);
config.customLaunchers = browserConfig;
config.reporters.push('saucelabs');
config.transports = [ 'xhr-polling' ];

config.sauceLabs = {
username: auth.SAUCE_USERNAME
, accessKey: auth.SAUCE_ACCESS_KEY
, startConnect: true
, tags: tags
, testName: 'ChaiJS'
, tunnelIdentifier: tunnel
};
};
@@ -0,0 +1,93 @@
/*!
* chai
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

var used = []
, exports = module.exports = {};

/*!
* Chai version
*/

exports.version = '3.5.0';

/*!
* Assertion Error
*/

exports.AssertionError = require('assertion-error');

/*!
* Utils for plugins (not exported)
*/

var util = require('./chai/utils');

/**
* # .use(function)
*
* Provides a way to extend the internals of Chai
*
* @param {Function}
* @returns {this} for chaining
* @api public
*/

exports.use = function (fn) {
if (!~used.indexOf(fn)) {
fn(this, util);
used.push(fn);
}

return this;
};

/*!
* Utility Functions
*/

exports.util = util;

/*!
* Configuration
*/

var config = require('./chai/config');
exports.config = config;

/*!
* Primary `Assertion` prototype
*/

var assertion = require('./chai/assertion');
exports.use(assertion);

/*!
* Core Assertions
*/

var core = require('./chai/core/assertions');
exports.use(core);

/*!
* Expect interface
*/

var expect = require('./chai/interface/expect');
exports.use(expect);

/*!
* Should interface
*/

var should = require('./chai/interface/should');
exports.use(should);

/*!
* Assert interface
*/

var assert = require('./chai/interface/assert');
exports.use(assert);
@@ -0,0 +1,131 @@
/*!
* chai
* http://chaijs.com
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

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

module.exports = function (_chai, util) {
/*!
* Module dependencies.
*/

var AssertionError = _chai.AssertionError
, flag = util.flag;

/*!
* Module export.
*/

_chai.Assertion = Assertion;

/*!
* Assertion Constructor
*
* Creates object for chaining.
*
* @api private
*/

function Assertion (obj, msg, stack) {
flag(this, 'ssfi', stack || arguments.callee);
flag(this, 'object', obj);
flag(this, 'message', msg);
}

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;
}
});

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.addProperty = function (name, fn) {
util.addProperty(this.prototype, name, fn);
};

Assertion.addMethod = function (name, fn) {
util.addMethod(this.prototype, name, fn);
};

Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
};

Assertion.overwriteProperty = function (name, fn) {
util.overwriteProperty(this.prototype, name, fn);
};

Assertion.overwriteMethod = function (name, fn) {
util.overwriteMethod(this.prototype, name, fn);
};

Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
};

/**
* ### .assert(expression, message, negateMessage, expected, actual, showDiff)
*
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
*
* @name assert
* @param {Philosophical} expression to be tested
* @param {String|Function} message or function that returns message to display if expression fails
* @param {String|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
*/

Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
var ok = util.test(this, arguments);
if (true !== showDiff) showDiff = false;
if (true !== config.showDiff) showDiff = false;

if (!ok) {
var msg = util.getMessage(this, arguments)
, actual = util.getActual(this, arguments);
throw new AssertionError(msg, {
actual: actual
, expected: expected
, showDiff: showDiff
}, (config.includeStack) ? this.assert : flag(this, 'ssfi'));
}
};

/*!
* ### ._obj
*
* Quick reference to stored `actual` value for plugin developers.
*
* @api private
*/

Object.defineProperty(Assertion.prototype, '_obj',
{ get: function () {
return flag(this, 'object');
}
, set: function (val) {
flag(this, 'object', val);
}
});
};
@@ -0,0 +1,55 @@
module.exports = {

/**
* ### config.includeStack
*
* User configurable property, influences whether stack trace
* is included in Assertion error message. Default of false
* suppresses stack trace in the error message.
*
* chai.config.includeStack = true; // enable stack on error
*
* @param {Boolean}
* @api public
*/

includeStack: false,

/**
* ### config.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.
*
* @param {Boolean}
* @api public
*/

showDiff: true,

/**
* ### config.truncateThreshold
*
* User configurable property, sets length threshold for actual and
* 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}
* @api public
*/

truncateThreshold: 40

};

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,34 @@
/*!
* chai
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

module.exports = function (chai, util) {
chai.expect = function (val, message) {
return new chai.Assertion(val, message);
};

/**
* ### .fail(actual, expected, [message], [operator])
*
* Throw a failure.
*
* @name fail
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @param {String} operator
* @namespace Expect
* @api public
*/

chai.expect.fail = function (actual, expected, message, operator) {
message = message || 'expect.fail()';
throw new chai.AssertionError(message, {
actual: actual
, expected: expected
, operator: operator
}, chai.expect.fail);
};
};
@@ -0,0 +1,201 @@
/*!
* chai
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

module.exports = function (chai, util) {
var Assertion = chai.Assertion;

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 || this instanceof Boolean ) {
return new Assertion(this.valueOf(), 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: shouldSetter
, get: shouldGetter
, configurable: true
});

var should = {};

/**
* ### .fail(actual, expected, [message], [operator])
*
* Throw a failure.
*
* @name fail
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @param {String} operator
* @namespace Should
* @api public
*/

should.fail = function (actual, expected, message, operator) {
message = message || 'should.fail()';
throw new chai.AssertionError(message, {
actual: actual
, expected: expected
, operator: operator
}, should.fail);
};

/**
* ### .equal(actual, expected, [message])
*
* Asserts non-strict equality (`==`) of `actual` and `expected`.
*
* should.equal(3, '3', '== coerces values to strings');
*
* @name equal
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @namespace Should
* @api public
*/

should.equal = function (val1, val2, msg) {
new Assertion(val1, msg).to.equal(val2);
};

/**
* ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
*
* Asserts that `function` will throw an error that is an instance of
* `constructor`, or alternately that it will throw an error with message
* matching `regexp`.
*
* should.throw(fn, 'function throws a reference error');
* should.throw(fn, /function throws a reference error/);
* should.throw(fn, ReferenceError);
* should.throw(fn, ReferenceError, 'function throws a reference error');
* should.throw(fn, ReferenceError, /function throws a reference error/);
*
* @name throw
* @alias Throw
* @param {Function} function
* @param {ErrorConstructor} constructor
* @param {RegExp} regexp
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @namespace Should
* @api public
*/

should.Throw = function (fn, errt, errs, msg) {
new Assertion(fn, msg).to.Throw(errt, errs);
};

/**
* ### .exist
*
* Asserts that the target is neither `null` nor `undefined`.
*
* var foo = 'hi';
*
* should.exist(foo, 'foo exists');
*
* @name exist
* @namespace Should
* @api public
*/

should.exist = function (val, msg) {
new Assertion(val, msg).to.exist;
}

// negation
should.not = {}

/**
* ### .not.equal(actual, expected, [message])
*
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
*
* should.not.equal(3, 4, 'these numbers are not equal');
*
* @name not.equal
* @param {Mixed} actual
* @param {Mixed} expected
* @param {String} message
* @namespace Should
* @api public
*/

should.not.equal = function (val1, val2, msg) {
new Assertion(val1, msg).to.not.equal(val2);
};

/**
* ### .throw(function, [constructor/regexp], [message])
*
* Asserts that `function` will _not_ throw an error that is an instance of
* `constructor`, or alternately that it will not throw an error with message
* matching `regexp`.
*
* should.not.throw(fn, Error, 'function does not throw');
*
* @name not.throw
* @alias not.Throw
* @param {Function} function
* @param {ErrorConstructor} constructor
* @param {RegExp} regexp
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @namespace Should
* @api public
*/

should.not.Throw = function (fn, errt, errs, msg) {
new Assertion(fn, msg).to.not.Throw(errt, errs);
};

/**
* ### .not.exist
*
* Asserts that the target is neither `null` nor `undefined`.
*
* var bar = null;
*
* should.not.exist(bar, 'bar does not exist');
*
* @name not.exist
* @namespace Should
* @api public
*/

should.not.exist = function (val, msg) {
new Assertion(val, msg).to.not.exist;
}

should['throw'] = should['Throw'];
should.not['throw'] = should.not['Throw'];

return should;
};

chai.should = loadShould;
chai.Should = loadShould;
};
@@ -0,0 +1,112 @@
/*!
* Chai - addChainingMethod utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/*!
* Module dependencies
*/

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

/*!
* Module variables
*/

// Check whether `__proto__` is supported
var hasProtoSupport = '__proto__' in Object;

// Without `__proto__` support, this module will need to add properties to a function.
// However, some Function.prototype methods cannot be overwritten,
// and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
var excludeNames = /^(?:length|name|arguments|caller)$/;

// Cache `Function` properties
var call = Function.prototype.call,
apply = Function.prototype.apply;

/**
* ### addChainableMethod (ctx, name, method, chainingBehavior)
*
* Adds a method to an object, such that the method can also be chained.
*
* utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
* var obj = utils.flag(this, 'object');
* new chai.Assertion(obj).to.be.equal(str);
* });
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
*
* The result can then be used as both a method assertion, executing both `method` and
* `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
*
* expect(fooStr).to.be.foo('bar');
* expect(fooStr).to.be.foo.equal('foo');
*
* @param {Object} ctx object to which the method is added
* @param {String} name of method to add
* @param {Function} method function to be used for `name`, when called
* @param {Function} chainingBehavior function to be called every time the property is accessed
* @namespace Utils
* @name addChainableMethod
* @api public
*/

module.exports = function (ctx, name, method, chainingBehavior) {
if (typeof chainingBehavior !== 'function') {
chainingBehavior = function () { };
}

var chainableBehavior = {
method: method
, chainingBehavior: chainingBehavior
};

// save the methods so we can overwrite them later, if we need to.
if (!ctx.__methods) {
ctx.__methods = {};
}
ctx.__methods[name] = chainableBehavior;

Object.defineProperty(ctx, name,
{ get: function () {
chainableBehavior.chainingBehavior.call(this);

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);
return result === undefined ? this : result;
};

// Use `__proto__` if available
if (hasProtoSupport) {
// Inherit all properties from the object by replacing the `Function` prototype
var prototype = assert.__proto__ = Object.create(this);
// Restore the `call` and `apply` methods from `Function`
prototype.call = call;
prototype.apply = apply;
}
// Otherwise, redefine all properties (slow!)
else {
var asserterNames = Object.getOwnPropertyNames(ctx);
asserterNames.forEach(function (asserterName) {
if (!excludeNames.test(asserterName)) {
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
Object.defineProperty(assert, asserterName, pd);
}
});
}

transferFlags(this, assert);
return assert;
}
, configurable: true
});
};
@@ -0,0 +1,44 @@
/*!
* Chai - addMethod utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

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

/**
* ### .addMethod (ctx, name, method)
*
* Adds a method to the prototype of an object.
*
* utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
* var obj = utils.flag(this, 'object');
* new chai.Assertion(obj).to.be.equal(str);
* });
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.addMethod('foo', fn);
*
* Then can be used as any other assertion.
*
* expect(fooStr).to.be.foo('bar');
*
* @param {Object} ctx object to which the method is added
* @param {String} name of method to add
* @param {Function} method function to be used for name
* @namespace Utils
* @name addMethod
* @api public
*/
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);
return result === undefined ? this : result;
};
};
@@ -0,0 +1,48 @@
/*!
* Chai - addProperty utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

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

/**
* ### addProperty (ctx, name, getter)
*
* Adds a property to the prototype of an object.
*
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
* var obj = utils.flag(this, 'object');
* new chai.Assertion(obj).to.be.instanceof(Foo);
* });
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.addProperty('foo', fn);
*
* Then can be used as any other assertion.
*
* expect(myFoo).to.be.foo;
*
* @param {Object} ctx object to which the property is added
* @param {String} name of property to add
* @param {Function} getter function to be used for name
* @namespace Utils
* @name addProperty
* @api public
*/

module.exports = function (ctx, name, getter) {
Object.defineProperty(ctx, name,
{ get: function addProperty() {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', addProperty);

var result = getter.call(this);
return result === undefined ? this : result;
}
, configurable: true
});
};
@@ -0,0 +1,42 @@
/*!
* Chai - expectTypes utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### expectTypes(obj, types)
*
* Ensures that the object being tested against is of a valid type.
*
* utils.expectTypes(this, ['array', 'object', 'string']);
*
* @param {Mixed} obj constructed Assertion
* @param {Array} type A list of allowed types for this assertion
* @namespace Utils
* @name expectTypes
* @api public
*/

var AssertionError = require('assertion-error');
var flag = require('./flag');
var type = require('type-detect');

module.exports = function (obj, types) {
var obj = flag(obj, 'object');
types = types.map(function (t) { return t.toLowerCase(); });
types.sort();

// Transforms ['lorem', 'ipsum'] into 'a lirum, or an ipsum'
var str = types.map(function (t, index) {
var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a';
var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
return or + art + ' ' + t;
}).join(', ');

if (!types.some(function (expected) { return type(obj) === expected; })) {
throw new AssertionError(
'object tested must be ' + str + ', but ' + type(obj) + ' given'
);
}
};
@@ -0,0 +1,33 @@
/*!
* Chai - flag utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### flag(object, key, [value])
*
* Get or set a flag value on an object. If a
* value is provided it will be set, else it will
* return the currently set value or `undefined` if
* the value is not set.
*
* utils.flag(this, 'foo', 'bar'); // setter
* utils.flag(this, 'foo'); // getter, returns `bar`
*
* @param {Object} object constructed Assertion
* @param {String} key
* @param {Mixed} value (optional)
* @namespace Utils
* @name flag
* @api private
*/

module.exports = function (obj, key, value) {
var flags = obj.__flags || (obj.__flags = Object.create(null));
if (arguments.length === 3) {
flags[key] = value;
} else {
return flags[key];
}
};
@@ -0,0 +1,20 @@
/*!
* Chai - getActual utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* # getActual(object, [actual])
*
* Returns the `actual` value for an Assertion
*
* @param {Object} object (constructed Assertion)
* @param {Arguments} chai.Assertion.prototype.assert arguments
* @namespace Utils
* @name getActual
*/

module.exports = function (obj, args) {
return args.length > 4 ? args[4] : obj._obj;
};
@@ -0,0 +1,26 @@
/*!
* Chai - getEnumerableProperties utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### .getEnumerableProperties(object)
*
* This allows the retrieval of enumerable property names of an object,
* inherited or not.
*
* @param {Object} object
* @returns {Array}
* @namespace Utils
* @name getEnumerableProperties
* @api public
*/

module.exports = function getEnumerableProperties(object) {
var result = [];
for (var name in object) {
result.push(name);
}
return result;
};
@@ -0,0 +1,51 @@
/*!
* Chai - message composition utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/*!
* Module dependancies
*/

var flag = require('./flag')
, getActual = require('./getActual')
, inspect = require('./inspect')
, objDisplay = require('./objDisplay');

/**
* ### .getMessage(object, message, negateMessage)
*
* Construct the error message based on flags
* and template tags. Template tags will return
* a stringified inspection of the object referenced.
*
* Message template tags:
* - `#{this}` current asserted object
* - `#{act}` actual value
* - `#{exp}` expected value
*
* @param {Object} object (constructed Assertion)
* @param {Arguments} chai.Assertion.prototype.assert arguments
* @namespace Utils
* @name getMessage
* @api public
*/

module.exports = function (obj, args) {
var negate = flag(obj, 'negate')
, val = flag(obj, 'object')
, expected = args[3]
, actual = getActual(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, function () { return objDisplay(val); })
.replace(/#\{act\}/g, function () { return objDisplay(actual); })
.replace(/#\{exp\}/g, function () { return objDisplay(expected); });

return flagMsg ? flagMsg + ': ' + msg : msg;
};
@@ -0,0 +1,22 @@
/*!
* Chai - getName utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* # getName(func)
*
* Gets the name of a function, in a cross-browser way.
*
* @param {Function} a function (usually a constructor)
* @namespace Utils
* @name getName
*/

module.exports = function (func) {
if (func.name) return func.name;

var match = /^\s?function ([^(]*)\(/.exec(func);
return match && match[1] ? match[1] : "";
};
@@ -0,0 +1,111 @@
/*!
* Chai - getPathInfo utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

var hasProperty = require('./hasProperty');

/**
* ### .getPathInfo(path, object)
*
* This allows the retrieval of property info in an
* object given a string path.
*
* The path info consists of an object with the
* following properties:
*
* * parent - The parent object of the property referenced by `path`
* * name - The name of the final property, a number if it was an array indexer
* * value - The value of the property, if it exists, otherwise `undefined`
* * exists - Whether the property exists or not
*
* @param {String} path
* @param {Object} object
* @returns {Object} info
* @namespace Utils
* @name getPathInfo
* @api public
*/

module.exports = function getPathInfo(path, obj) {
var parsed = parsePath(path),
last = parsed[parsed.length - 1];

var info = {
parent: parsed.length > 1 ? _getPathValue(parsed, obj, parsed.length - 1) : obj,
name: last.p || last.i,
value: _getPathValue(parsed, obj)
};
info.exists = hasProperty(info.name, info.parent);

return info;
};


/*!
* ## parsePath(path)
*
* Helper function used to parse string object
* paths. Use in conjunction with `_getPathValue`.
*
* var parsed = parsePath('myobject.property.subprop');
*
* ### Paths:
*
* * 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, '$1.[')
, parts = str.match(/(\\\.|[^.]+?)+/g);
return parts.map(function (value) {
var re = /^\[(\d+)\]$/
, mArr = re.exec(value);
if (mArr) return { i: parseFloat(mArr[1]) };
else return { p: value.replace(/\\([.\[\]])/g, '$1') };
});
}


/*!
* ## _getPathValue(parsed, obj)
*
* Helper companion function for `.parsePath` that returns
* the value located at the parsed address.
*
* var value = getPathValue(parsed, obj);
*
* @param {Object} parsed definition from `parsePath`.
* @param {Object} object to search against
* @param {Number} object to search against
* @returns {Object|Undefined} value
* @api private
*/

function _getPathValue (parsed, obj, index) {
var tmp = obj
, res;

index = (index === undefined ? parsed.length : index);

for (var i = 0, l = index; i < l; i++) {
var part = parsed[i];
if (tmp) {
if ('undefined' !== typeof part.p)
tmp = tmp[part.p];
else if ('undefined' !== typeof part.i)
tmp = tmp[part.i];
if (i == (l - 1)) res = tmp;
} else {
res = undefined;
}
}
return res;
}
@@ -0,0 +1,43 @@
/*!
* Chai - getPathValue utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* @see https://github.com/logicalparadox/filtr
* MIT Licensed
*/

var getPathInfo = require('./getPathInfo');

/**
* ### .getPathValue(path, object)
*
* This allows the retrieval of values in an
* object given a string path.
*
* var obj = {
* prop1: {
* arr: ['a', 'b', 'c']
* , str: 'Hello'
* }
* , prop2: {
* arr: [ { nested: 'Universe' } ]
* , str: 'Hello again!'
* }
* }
*
* The following would be the results.
*
* getPathValue('prop1.str', obj); // Hello
* getPathValue('prop1.att[2]', obj); // b
* getPathValue('prop2.arr[0].nested', obj); // Universe
*
* @param {String} path
* @param {Object} object
* @returns {Object} value or `undefined`
* @namespace Utils
* @name getPathValue
* @api public
*/
module.exports = function(path, obj) {
var info = getPathInfo(path, obj);
return info.value;
};
@@ -0,0 +1,36 @@
/*!
* Chai - getProperties utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### .getProperties(object)
*
* This allows the retrieval of property names of an object, enumerable or not,
* inherited or not.
*
* @param {Object} object
* @returns {Array}
* @namespace Utils
* @name getProperties
* @api public
*/

module.exports = function getProperties(object) {
var result = Object.getOwnPropertyNames(object);

function addProperty(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
}

var proto = Object.getPrototypeOf(object);
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}

return result;
};
@@ -0,0 +1,64 @@
/*!
* Chai - hasProperty utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

var type = require('type-detect');

/**
* ### .hasProperty(object, name)
*
* This allows checking whether an object has
* named property or numeric array index.
*
* Basically does the same thing as the `in`
* operator but works properly with natives
* and null/undefined values.
*
* var obj = {
* arr: ['a', 'b', 'c']
* , str: 'Hello'
* }
*
* The following would be the results.
*
* hasProperty('str', obj); // true
* hasProperty('constructor', obj); // true
* hasProperty('bar', obj); // false
*
* hasProperty('length', obj.str); // true
* hasProperty(1, obj.str); // true
* hasProperty(5, obj.str); // false
*
* hasProperty('length', obj.arr); // true
* hasProperty(2, obj.arr); // true
* hasProperty(3, obj.arr); // false
*
* @param {Objuect} object
* @param {String|Number} name
* @returns {Boolean} whether it exists
* @namespace Utils
* @name getPathInfo
* @api public
*/

var literals = {
'number': Number
, 'string': String
};

module.exports = function hasProperty(name, obj) {
var ot = type(obj);

// Bad Object, obviously no props at all
if(ot === 'null' || ot === 'undefined')
return false;

// The `in` operator does not work with certain literals
// box these before the check
if(literals[ot] && typeof obj !== 'object')
obj = new literals[ot](obj);

return name in obj;
};
@@ -0,0 +1,130 @@
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/*!
* Main exports
*/

var exports = module.exports = {};

/*!
* test utility
*/

exports.test = require('./test');

/*!
* type utility
*/

exports.type = require('type-detect');

/*!
* expectTypes utility
*/
exports.expectTypes = require('./expectTypes');

/*!
* message utility
*/

exports.getMessage = require('./getMessage');

/*!
* actual utility
*/

exports.getActual = require('./getActual');

/*!
* Inspect util
*/

exports.inspect = require('./inspect');

/*!
* Object Display util
*/

exports.objDisplay = require('./objDisplay');

/*!
* Flag utility
*/

exports.flag = require('./flag');

/*!
* Flag transferring utility
*/

exports.transferFlags = require('./transferFlags');

/*!
* Deep equal utility
*/

exports.eql = require('deep-eql');

/*!
* Deep path value
*/

exports.getPathValue = require('./getPathValue');

/*!
* Deep path info
*/

exports.getPathInfo = require('./getPathInfo');

/*!
* Check if a property exists
*/

exports.hasProperty = require('./hasProperty');

/*!
* Function name
*/

exports.getName = require('./getName');

/*!
* add Property
*/

exports.addProperty = require('./addProperty');

/*!
* add Method
*/

exports.addMethod = require('./addMethod');

/*!
* overwrite Property
*/

exports.overwriteProperty = require('./overwriteProperty');

/*!
* overwrite Method
*/

exports.overwriteMethod = require('./overwriteMethod');

/*!
* Add a chainable method
*/

exports.addChainableMethod = require('./addChainableMethod');

/*!
* Overwrite chainable method
*/

exports.overwriteChainableMethod = require('./overwriteChainableMethod');
@@ -0,0 +1,335 @@
// This is (almost) directly from Node.js utils
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js

var getName = require('./getName');
var getProperties = require('./getProperties');
var getEnumerableProperties = require('./getEnumerableProperties');

module.exports = inspect;

/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
* properties of objects.
* @param {Number} depth Depth in which to descend in object. Default is 2.
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
* output. Default is false (no coloring).
* @namespace Utils
* @name inspect
*/
function inspect(obj, showHidden, depth, colors) {
var ctx = {
showHidden: showHidden,
seen: [],
stylize: function (str) { return str; }
};
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
}

// Returns true if object is a DOM element.
var isDOMElement = function (object) {
if (typeof HTMLElement === 'object') {
return object instanceof HTMLElement;
} else {
return object &&
typeof object === 'object' &&
object.nodeType === 1 &&
typeof object.nodeName === 'string';
}
};

function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
var ret = value.inspect(recurseTimes);
if (typeof ret !== 'string') {
ret = formatValue(ctx, ret, recurseTimes);
}
return ret;
}

// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}

// If this is a DOM element, try to get the outer HTML.
if (isDOMElement(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.
var visibleKeys = getEnumerableProperties(value);
var keys = ctx.showHidden ? getProperties(value) : visibleKeys;

// Some type of object without properties can be shortcutted.
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,
// a `stack` plus `description` property; ignore those for consistency.
if (keys.length === 0 || (isError(value) && (
(keys.length === 1 && keys[0] === 'stack') ||
(keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')
))) {
if (typeof value === 'function') {
var name = getName(value);
var nameSuffix = name ? ': ' + name : '';
return ctx.stylize('[Function' + nameSuffix + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}

var base = '', array = false, braces = ['{', '}'];

// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}

// Make functions say that they are functions
if (typeof value === 'function') {
var name = getName(value);
var nameSuffix = name ? ': ' + name : '';
base = ' [Function' + nameSuffix + ']';
}

// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}

// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}

// Make error with message first say the error
if (isError(value)) {
return formatError(value);
}

if (keys.length === 0 && (!array || value.length == 0)) {
return braces[0] + base + braces[1];
}

if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}

ctx.seen.push(value);

var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}

ctx.seen.pop();

return reduceToSingleString(output, base, braces);
}


function formatPrimitive(ctx, value) {
switch (typeof value) {
case 'undefined':
return ctx.stylize('undefined', 'undefined');

case 'string':
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');

case 'number':
if (value === 0 && (1/value) === -Infinity) {
return ctx.stylize('-0', 'number');
}
return ctx.stylize('' + value, 'number');

case 'boolean':
return ctx.stylize('' + value, 'boolean');
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
return ctx.stylize('null', 'null');
}
}


function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}


function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}


function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str;
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (value.__lookupSetter__(key)) {
str = ctx.stylize('[Setter]', 'special');
}
}
}
if (visibleKeys.indexOf(key) < 0) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(value[key]) < 0) {
if (recurseTimes === null) {
str = formatValue(ctx, value[key], null);
} else {
str = formatValue(ctx, value[key], recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (typeof name === 'undefined') {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}

return name + ': ' + str;
}


function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.length + 1;
}, 0);

if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}

return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}

function isArray(ar) {
return Array.isArray(ar) ||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
}

function isRegExp(re) {
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
}

function isDate(d) {
return typeof d === 'object' && objectToString(d) === '[object Date]';
}

function isError(e) {
return typeof e === 'object' && objectToString(e) === '[object Error]';
}

function objectToString(o) {
return Object.prototype.toString.call(o);
}
@@ -0,0 +1,50 @@
/*!
* Chai - flag utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/*!
* Module dependancies
*/

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

/**
* ### .objDisplay (object)
*
* Determines if an object or an array matches
* criteria to be inspected in-line for error
* messages or should be truncated.
*
* @param {Mixed} javascript object to inspect
* @name objDisplay
* @namespace Utils
* @api public
*/

module.exports = function (obj) {
var str = inspect(obj)
, type = Object.prototype.toString.call(obj);

if (config.truncateThreshold && str.length >= config.truncateThreshold) {
if (type === '[object Function]') {
return !obj.name || obj.name === ''
? '[Function]'
: '[Function: ' + obj.name + ']';
} else if (type === '[object Array]') {
return '[ Array(' + obj.length + ') ]';
} else if (type === '[object Object]') {
var keys = Object.keys(obj)
, kstr = keys.length > 2
? keys.splice(0, 2).join(', ') + ', ...'
: keys.join(', ');
return '{ Object (' + kstr + ') }';
} else {
return str;
}
} else {
return str;
}
};
@@ -0,0 +1,54 @@
/*!
* Chai - overwriteChainableMethod utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### overwriteChainableMethod (ctx, name, method, chainingBehavior)
*
* Overwites an already existing chainable method
* and provides access to the previous function or
* property. Must return functions to be used for
* name.
*
* utils.overwriteChainableMethod(chai.Assertion.prototype, 'length',
* function (_super) {
* }
* , function (_super) {
* }
* );
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.overwriteChainableMethod('foo', fn, fn);
*
* Then can be used as any other assertion.
*
* expect(myFoo).to.have.length(3);
* expect(myFoo).to.have.length.above(3);
*
* @param {Object} ctx object whose method / property is to be overwritten
* @param {String} name of method / property to overwrite
* @param {Function} method function that returns a function to be used for name
* @param {Function} chainingBehavior function that returns a function to be used for property
* @namespace Utils
* @name overwriteChainableMethod
* @api public
*/

module.exports = function (ctx, name, method, chainingBehavior) {
var chainableBehavior = ctx.__methods[name];

var _chainingBehavior = chainableBehavior.chainingBehavior;
chainableBehavior.chainingBehavior = function () {
var result = chainingBehavior(_chainingBehavior).call(this);
return result === undefined ? this : result;
};

var _method = chainableBehavior.method;
chainableBehavior.method = function () {
var result = method(_method).apply(this, arguments);
return result === undefined ? this : result;
};
};
@@ -0,0 +1,52 @@
/*!
* Chai - overwriteMethod utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### overwriteMethod (ctx, name, fn)
*
* Overwites an already existing method and provides
* access to previous function. Must return function
* to be used for name.
*
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
* return function (str) {
* var obj = utils.flag(this, 'object');
* if (obj instanceof Foo) {
* new chai.Assertion(obj.value).to.equal(str);
* } else {
* _super.apply(this, arguments);
* }
* }
* });
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.overwriteMethod('foo', fn);
*
* Then can be used as any other assertion.
*
* expect(myFoo).to.equal('bar');
*
* @param {Object} ctx object whose method is to be overwritten
* @param {String} name of method to overwrite
* @param {Function} method function that returns a function to be used for name
* @namespace Utils
* @name overwriteMethod
* @api public
*/

module.exports = function (ctx, name, method) {
var _method = ctx[name]
, _super = function () { return this; };

if (_method && 'function' === typeof _method)
_super = _method;

ctx[name] = function () {
var result = method(_super).apply(this, arguments);
return result === undefined ? this : result;
}
};
@@ -0,0 +1,55 @@
/*!
* Chai - overwriteProperty utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### overwriteProperty (ctx, name, fn)
*
* Overwites an already existing property getter and provides
* access to previous value. Must return function to use as getter.
*
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
* return function () {
* var obj = utils.flag(this, 'object');
* if (obj instanceof Foo) {
* new chai.Assertion(obj.name).to.equal('bar');
* } else {
* _super.call(this);
* }
* }
* });
*
*
* Can also be accessed directly from `chai.Assertion`.
*
* chai.Assertion.overwriteProperty('foo', fn);
*
* Then can be used as any other assertion.
*
* expect(myFoo).to.be.ok;
*
* @param {Object} ctx object whose property is to be overwritten
* @param {String} name of property to overwrite
* @param {Function} getter function that returns a getter function to be used for name
* @namespace Utils
* @name overwriteProperty
* @api public
*/

module.exports = function (ctx, name, getter) {
var _get = Object.getOwnPropertyDescriptor(ctx, name)
, _super = function () {};

if (_get && 'function' === typeof _get.get)
_super = _get.get

Object.defineProperty(ctx, name,
{ get: function () {
var result = getter(_super).call(this);
return result === undefined ? this : result;
}
, configurable: true
});
};
@@ -0,0 +1,28 @@
/*!
* Chai - test utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/*!
* Module dependancies
*/

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

/**
* # test(object, expression)
*
* Test and object for expression.
*
* @param {Object} object (constructed Assertion)
* @param {Arguments} chai.Assertion.prototype.assert arguments
* @namespace Utils
* @name test
*/

module.exports = function (obj, args) {
var negate = flag(obj, 'negate')
, expr = args[0];
return negate ? !expr : expr;
};
@@ -0,0 +1,45 @@
/*!
* Chai - transferFlags utility
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/

/**
* ### transferFlags(assertion, object, includeAll = true)
*
* Transfer all the flags for `assertion` to `object`. If
* `includeAll` is set to `false`, then the base Chai
* assertion flags (namely `object`, `ssfi`, and `message`)
* will not be transferred.
*
*
* var newAssertion = new Assertion();
* utils.transferFlags(assertion, newAssertion);
*
* var anotherAsseriton = new Assertion(myObj);
* utils.transferFlags(assertion, anotherAssertion, false);
*
* @param {Assertion} assertion the assertion to transfer the flags from
* @param {Object} object the object to transfer the flags to; usually a new assertion
* @param {Boolean} includeAll
* @namespace Utils
* @name transferFlags
* @api private
*/

module.exports = function (assertion, object, includeAll) {
var flags = assertion.__flags || (assertion.__flags = Object.create(null));

if (!object.__flags) {
object.__flags = Object.create(null);
}

includeAll = arguments.length === 3 ? includeAll : true;

for (var flag in flags) {
if (includeAll ||
(flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
object.__flags[flag] = flags[flag];
}
}
};
@@ -0,0 +1,129 @@
{
"_args": [
[
{
"raw": "chai",
"scope": null,
"escapedName": "chai",
"name": "chai",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"/Users/milkman/turing/projects/ironfest"
]
],
"_from": "chai@latest",
"_id": "chai@3.5.0",
"_inCache": true,
"_installable": true,
"_location": "/chai",
"_nodeVersion": "5.5.0",
"_npmUser": {
"name": "chaijs",
"email": "chaijs@keithcirkel.co.uk"
},
"_npmVersion": "3.3.12",
"_phantomChildren": {},
"_requested": {
"raw": "chai",
"scope": null,
"escapedName": "chai",
"name": "chai",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
"_shasum": "4d02637b067fe958bdbfdd3a40ec56fef7373247",
"_shrinkwrap": null,
"_spec": "chai",
"_where": "/Users/milkman/turing/projects/ironfest",
"author": {
"name": "Jake Luer",
"email": "jake@alogicalparadox.com"
},
"bugs": {
"url": "https://github.com/chaijs/chai/issues"
},
"contributors": [
{
"name": "Jake Luer",
"email": "jake@alogicalparadox.com"
},
{
"name": "Domenic Denicola",
"email": "domenic@domenicdenicola.com",
"url": "http://domenicdenicola.com"
},
{
"name": "Veselin Todorov",
"email": "hi@vesln.com"
},
{
"name": "John Firebaugh",
"email": "john.firebaugh@gmail.com"
}
],
"dependencies": {
"assertion-error": "^1.0.1",
"deep-eql": "^0.1.3",
"type-detect": "^1.0.0"
},
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
"devDependencies": {
"browserify": "^10.2.1",
"bump-cli": "^1.1.3",
"istanbul": "^0.3.14",
"karma": "^0.13.16",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.1.10",
"karma-phantomjs-launcher": "^0.2.0",
"karma-sauce-launcher": "^0.2.11",
"mocha": "^2.2.5"
},
"directories": {},
"dist": {
"shasum": "4d02637b067fe958bdbfdd3a40ec56fef7373247",
"tarball": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz"
},
"engines": {
"node": ">= 0.4.0"
},
"gitHead": "4ca0218391cf947c6cfac2d1a7424a63a4b4c232",
"homepage": "http://chaijs.com",
"keywords": [
"test",
"assertion",
"assert",
"testing",
"chai"
],
"license": "MIT",
"main": "./index",
"maintainers": [
{
"name": "jakeluer",
"email": "jake@alogicalparadox.com"
},
{
"name": "chaijs",
"email": "chaijs@keithcirkel.co.uk"
}
],
"name": "chai",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/chaijs/chai.git"
},
"scripts": {
"test": "make test"
},
"version": "3.5.0"
}
@@ -0,0 +1,128 @@

/*!
* Chrome
*/

exports['SL_Chrome'] = {
base: 'SauceLabs'
, browserName: 'chrome'
};

/*!
* Firefox
*/

/*!
* TODO: Karma doesn't seem to like this, though sauce boots its up
*
exports['SL_Firefox_23'] = {
base: 'SauceLabs'
, browserName: 'firefox'
, platform: 'Windows XP'
, version: '23'
};
*/

exports['SL_Firefox_22'] = {
base: 'SauceLabs'
, browserName: 'firefox'
, platform: 'Windows 7'
, version: '22'
};

/*!
* Opera
*/

exports['SL_Opera_12'] = {
base: 'SauceLabs'
, browserName: 'opera'
, platform: 'Windows 7'
, version: '12'
};

exports['SL_Opera_11'] = {
base: 'SauceLabs'
, browserName: 'opera'
, platform: 'Windows 7'
, version: '11'
};

/*!
* Internet Explorer
*/

exports['SL_IE_10'] = {
base: 'SauceLabs'
, browserName: 'internet explorer'
, platform: 'Windows 2012'
, version: '10'
};

/*!
* Safari
*/

exports['SL_Safari_6'] = {
base: 'SauceLabs'
, browserName: 'safari'
, platform: 'Mac 10.8'
, version: '6'
};

exports['SL_Safari_5'] = {
base: 'SauceLabs'
, browserName: 'safari'
, platform: 'Mac 10.6'
, version: '5'
};

/*!
* iPhone
*/

/*!
* TODO: These take forever to boot or shut down. Causes timeout.
*
exports['SL_iPhone_6'] = {
base: 'SauceLabs'
, browserName: 'iphone'
, platform: 'Mac 10.8'
, version: '6'
};
exports['SL_iPhone_5-1'] = {
base: 'SauceLabs'
, browserName: 'iphone'
, platform: 'Mac 10.8'
, version: '5.1'
};
exports['SL_iPhone_5'] = {
base: 'SauceLabs'
, browserName: 'iphone'
, platform: 'Mac 10.6'
, version: '5'
};
*/

/*!
* Android
*/

/*!
* TODO: fails because of error serialization
*
exports['SL_Android_4'] = {
base: 'SauceLabs'
, browserName: 'android'
, platform: 'Linux'
, version: '4'
};
*/
@@ -11,6 +11,25 @@ const path = require('path');
const MongoClient = require('mongodb').MongoClient



// var { assert } = require('../app/node_modules/chai');
//
// describe('IronFE', function() {
// it('vowel check should return true ALEX', function() {
// assert.equal(true, true)
// })
// it('vowel check should return true ALEX', function() {
// assert.equal(false, true)
// })
// })

//assert for localhost:
//var { assert } = require('../chai');


//assert for server:
//var { assert } = require('../app/node_modules/chai');

// if(process.env.NODE_ENV === ){
//
// }
@@ -27,36 +46,44 @@ if(app.settings.env === "development"){
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies

// if (!fs.existsSync(temp_dir)){
// fs.mkdir(temp_dir, function(){
// fs.open('/tmp/test.js', 'w', function(){
//
// });
// });
// }

function runMochaTests() {
Object.keys( require.cache ).forEach( function( file ) {
delete require.cache[ file ];
} );
var mocha = new Mocha();
// mocha.addFile( 'run_test.js' );
mocha.addFile('/tmp/test.js');
mocha.run();
// mocha.addFile('/tmp/test.js');
mocha.addFile(temp_dir);
return mocha.run()
}

app.post('/api/newtest', (request, response) => {
console.log(request.body)

// fs.open(path.join(temp_dir, 'test.js'), 'w', function(){
// fs.open(temp_dir, 'w', function(){
// fs.writeFile(temp_dir, request.body.test, (err) => {
// runMochaTests();
// });
// });
fs.open('/tmp/test.js', 'w', function(){
fs.writeFile('/tmp/test.js', request.body.test, (err) => {
runMochaTests();
var testArray = []
fs.open(temp_dir, 'w', function(){
return fs.writeFile(temp_dir, request.body.test, (err) => {
// fs.open('/tmp/test.js', 'w', function(){
// fs.writeFile('/tmp/test.js', request.body.test, (err) => {
const runner = runMochaTests();
runner.on('pass', (test)=>{
let testDetails = {
title: test.title,
body: test.body,
state: test.state,
error: test.err
}
testArray.push(testDetails)
})
runner.on('fail', (test)=>{
let testDetails = {
title: test.title,
body: test.body,
state: test.state,
error: test.err
}
testArray.push(testDetails)
})
runner.on('end', (test)=>{
response.status(200).send(testArray)
})
});
});
});
@@ -1,7 +1,11 @@
var { assert } = require('chai');

var { assert } = require('../chai');

describe('IronFE', function() {
it('vowel check should return true ALEXwdeddzza', function() {
it('vowel check should return true ALEX', function() {
assert.equal(true, true)
})
it('vowel check should return true ALEX', function() {
assert.equal(false, true)
})
})
BIN +40 KB sketch.sketch
Binary file not shown.
@@ -53,10 +53,10 @@ class App extends Component {
body: JSON.stringify({
main: this.state.mainCode,
test: this.state.testCode
// test: fakeTest
})
})
.then((res)=>{
console.log(res);
return res.json()
})
.then((res)=>{