chai 1.8.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +1 -1
- package/CONTRIBUTING.md +173 -0
- package/History.md +93 -0
- package/README.md +60 -40
- package/ReleaseNotes.md +156 -0
- package/bower.json +1 -1
- package/chai.js +354 -163
- package/karma.conf.js +4 -5
- package/lib/chai/assertion.js +31 -31
- package/lib/chai/config.js +50 -0
- package/lib/chai/core/assertions.js +76 -21
- package/lib/chai/interface/assert.js +15 -39
- package/lib/chai/interface/expect.js +1 -1
- package/lib/chai/interface/should.js +27 -25
- package/lib/chai/utils/addChainableMethod.js +22 -5
- package/lib/chai/utils/addMethod.js +7 -1
- package/lib/chai/utils/addProperty.js +1 -1
- package/lib/chai/utils/flag.js +1 -1
- package/lib/chai/utils/getActual.js +2 -3
- package/lib/chai/utils/getEnumerableProperties.js +1 -1
- package/lib/chai/utils/getMessage.js +2 -1
- package/lib/chai/utils/getName.js +1 -1
- package/lib/chai/utils/getPathValue.js +1 -1
- package/lib/chai/utils/getProperties.js +1 -1
- package/lib/chai/utils/index.js +6 -0
- package/lib/chai/utils/inspect.js +30 -20
- package/lib/chai/utils/objDisplay.js +3 -2
- package/lib/chai/utils/overwriteChainableMethod.js +53 -0
- package/lib/chai/utils/overwriteMethod.js +1 -1
- package/lib/chai/utils/overwriteProperty.js +1 -1
- package/lib/chai/utils/test.js +1 -1
- package/lib/chai/utils/transferFlags.js +1 -1
- package/lib/chai/utils/type.js +1 -1
- package/lib/chai.js +9 -2
- package/package.json +7 -8
package/chai.js
CHANGED
|
@@ -725,7 +725,7 @@ module.exports = require('./lib/chai');
|
|
|
725
725
|
require.register("chai/lib/chai.js", function(exports, require, module){
|
|
726
726
|
/*!
|
|
727
727
|
* chai
|
|
728
|
-
* Copyright(c) 2011-
|
|
728
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
729
729
|
* MIT Licensed
|
|
730
730
|
*/
|
|
731
731
|
|
|
@@ -736,7 +736,7 @@ var used = []
|
|
|
736
736
|
* Chai version
|
|
737
737
|
*/
|
|
738
738
|
|
|
739
|
-
exports.version = '1.
|
|
739
|
+
exports.version = '1.9.2';
|
|
740
740
|
|
|
741
741
|
/*!
|
|
742
742
|
* Assertion Error
|
|
@@ -769,6 +769,13 @@ exports.use = function (fn) {
|
|
|
769
769
|
return this;
|
|
770
770
|
};
|
|
771
771
|
|
|
772
|
+
/*!
|
|
773
|
+
* Configuration
|
|
774
|
+
*/
|
|
775
|
+
|
|
776
|
+
var config = require('./chai/config');
|
|
777
|
+
exports.config = config;
|
|
778
|
+
|
|
772
779
|
/*!
|
|
773
780
|
* Primary `Assertion` prototype
|
|
774
781
|
*/
|
|
@@ -809,10 +816,12 @@ require.register("chai/lib/chai/assertion.js", function(exports, require, module
|
|
|
809
816
|
/*!
|
|
810
817
|
* chai
|
|
811
818
|
* http://chaijs.com
|
|
812
|
-
* Copyright(c) 2011-
|
|
819
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
813
820
|
* MIT Licensed
|
|
814
821
|
*/
|
|
815
822
|
|
|
823
|
+
var config = require('./config');
|
|
824
|
+
|
|
816
825
|
module.exports = function (_chai, util) {
|
|
817
826
|
/*!
|
|
818
827
|
* Module dependencies.
|
|
@@ -841,33 +850,27 @@ module.exports = function (_chai, util) {
|
|
|
841
850
|
flag(this, 'message', msg);
|
|
842
851
|
}
|
|
843
852
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
*/
|
|
855
|
-
|
|
856
|
-
Assertion.includeStack = false;
|
|
857
|
-
|
|
858
|
-
/*!
|
|
859
|
-
* ### Assertion.showDiff
|
|
860
|
-
*
|
|
861
|
-
* User configurable property, influences whether or not
|
|
862
|
-
* the `showDiff` flag should be included in the thrown
|
|
863
|
-
* AssertionErrors. `false` will always be `false`; `true`
|
|
864
|
-
* will be true when the assertion has requested a diff
|
|
865
|
-
* be shown.
|
|
866
|
-
*
|
|
867
|
-
* @api public
|
|
868
|
-
*/
|
|
853
|
+
Object.defineProperty(Assertion, 'includeStack', {
|
|
854
|
+
get: function() {
|
|
855
|
+
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
|
856
|
+
return config.includeStack;
|
|
857
|
+
},
|
|
858
|
+
set: function(value) {
|
|
859
|
+
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
|
860
|
+
config.includeStack = value;
|
|
861
|
+
}
|
|
862
|
+
});
|
|
869
863
|
|
|
870
|
-
Assertion
|
|
864
|
+
Object.defineProperty(Assertion, 'showDiff', {
|
|
865
|
+
get: function() {
|
|
866
|
+
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
|
867
|
+
return config.showDiff;
|
|
868
|
+
},
|
|
869
|
+
set: function(value) {
|
|
870
|
+
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
|
871
|
+
config.showDiff = value;
|
|
872
|
+
}
|
|
873
|
+
});
|
|
871
874
|
|
|
872
875
|
Assertion.addProperty = function (name, fn) {
|
|
873
876
|
util.addProperty(this.prototype, name, fn);
|
|
@@ -889,6 +892,10 @@ module.exports = function (_chai, util) {
|
|
|
889
892
|
util.overwriteMethod(this.prototype, name, fn);
|
|
890
893
|
};
|
|
891
894
|
|
|
895
|
+
Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
|
|
896
|
+
util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
897
|
+
};
|
|
898
|
+
|
|
892
899
|
/*!
|
|
893
900
|
* ### .assert(expression, message, negateMessage, expected, actual)
|
|
894
901
|
*
|
|
@@ -896,8 +903,8 @@ module.exports = function (_chai, util) {
|
|
|
896
903
|
*
|
|
897
904
|
* @name assert
|
|
898
905
|
* @param {Philosophical} expression to be tested
|
|
899
|
-
* @param {String} message to display if fails
|
|
900
|
-
* @param {String} negatedMessage to display if negated expression fails
|
|
906
|
+
* @param {String or Function} message or function that returns message to display if fails
|
|
907
|
+
* @param {String or Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
|
|
901
908
|
* @param {Mixed} expected value (remember to check for negation)
|
|
902
909
|
* @param {Mixed} actual (optional) will default to `this.obj`
|
|
903
910
|
* @api private
|
|
@@ -906,7 +913,7 @@ module.exports = function (_chai, util) {
|
|
|
906
913
|
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
|
|
907
914
|
var ok = util.test(this, arguments);
|
|
908
915
|
if (true !== showDiff) showDiff = false;
|
|
909
|
-
if (true !==
|
|
916
|
+
if (true !== config.showDiff) showDiff = false;
|
|
910
917
|
|
|
911
918
|
if (!ok) {
|
|
912
919
|
var msg = util.getMessage(this, arguments)
|
|
@@ -915,7 +922,7 @@ module.exports = function (_chai, util) {
|
|
|
915
922
|
actual: actual
|
|
916
923
|
, expected: expected
|
|
917
924
|
, showDiff: showDiff
|
|
918
|
-
}, (
|
|
925
|
+
}, (config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
|
919
926
|
}
|
|
920
927
|
};
|
|
921
928
|
|
|
@@ -937,12 +944,65 @@ module.exports = function (_chai, util) {
|
|
|
937
944
|
});
|
|
938
945
|
};
|
|
939
946
|
|
|
947
|
+
});
|
|
948
|
+
require.register("chai/lib/chai/config.js", function(exports, require, module){
|
|
949
|
+
module.exports = {
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* ### config.includeStack
|
|
953
|
+
*
|
|
954
|
+
* User configurable property, influences whether stack trace
|
|
955
|
+
* is included in Assertion error message. Default of false
|
|
956
|
+
* suppresses stack trace in the error message.
|
|
957
|
+
*
|
|
958
|
+
* chai.config.includeStack = true; // enable stack on error
|
|
959
|
+
*
|
|
960
|
+
* @param {Boolean}
|
|
961
|
+
* @api public
|
|
962
|
+
*/
|
|
963
|
+
|
|
964
|
+
includeStack: false,
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* ### config.showDiff
|
|
968
|
+
*
|
|
969
|
+
* User configurable property, influences whether or not
|
|
970
|
+
* the `showDiff` flag should be included in the thrown
|
|
971
|
+
* AssertionErrors. `false` will always be `false`; `true`
|
|
972
|
+
* will be true when the assertion has requested a diff
|
|
973
|
+
* be shown.
|
|
974
|
+
*
|
|
975
|
+
* @param {Boolean}
|
|
976
|
+
* @api public
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
showDiff: true,
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* ### config.truncateThreshold
|
|
983
|
+
*
|
|
984
|
+
* User configurable property, sets length threshold for actual and
|
|
985
|
+
* expected values in assertion errors. If this threshold is exceeded,
|
|
986
|
+
* the value is truncated.
|
|
987
|
+
*
|
|
988
|
+
* Set it to zero if you want to disable truncating altogether.
|
|
989
|
+
*
|
|
990
|
+
* chai.config.truncateThreshold = 0; // disable truncating
|
|
991
|
+
*
|
|
992
|
+
* @param {Number}
|
|
993
|
+
* @api public
|
|
994
|
+
*/
|
|
995
|
+
|
|
996
|
+
truncateThreshold: 40
|
|
997
|
+
|
|
998
|
+
};
|
|
999
|
+
|
|
940
1000
|
});
|
|
941
1001
|
require.register("chai/lib/chai/core/assertions.js", function(exports, require, module){
|
|
942
1002
|
/*!
|
|
943
1003
|
* chai
|
|
944
1004
|
* http://chaijs.com
|
|
945
|
-
* Copyright(c) 2011-
|
|
1005
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
946
1006
|
* MIT Licensed
|
|
947
1007
|
*/
|
|
948
1008
|
|
|
@@ -954,9 +1014,9 @@ module.exports = function (chai, _) {
|
|
|
954
1014
|
/**
|
|
955
1015
|
* ### Language Chains
|
|
956
1016
|
*
|
|
957
|
-
* The following are
|
|
1017
|
+
* The following are provided as chainable getters to
|
|
958
1018
|
* improve the readability of your assertions. They
|
|
959
|
-
* do not provide
|
|
1019
|
+
* do not provide testing capabilities unless they
|
|
960
1020
|
* have been overwritten by a plugin.
|
|
961
1021
|
*
|
|
962
1022
|
* **Chains**
|
|
@@ -967,6 +1027,7 @@ module.exports = function (chai, _) {
|
|
|
967
1027
|
* - is
|
|
968
1028
|
* - that
|
|
969
1029
|
* - and
|
|
1030
|
+
* - has
|
|
970
1031
|
* - have
|
|
971
1032
|
* - with
|
|
972
1033
|
* - at
|
|
@@ -978,7 +1039,7 @@ module.exports = function (chai, _) {
|
|
|
978
1039
|
*/
|
|
979
1040
|
|
|
980
1041
|
[ 'to', 'be', 'been'
|
|
981
|
-
, 'is', 'and', 'have'
|
|
1042
|
+
, 'is', 'and', 'has', 'have'
|
|
982
1043
|
, 'with', 'that', 'at'
|
|
983
1044
|
, 'of', 'same' ].forEach(function (chain) {
|
|
984
1045
|
Assertion.addProperty(chain, function () {
|
|
@@ -1086,9 +1147,28 @@ module.exports = function (chai, _) {
|
|
|
1086
1147
|
|
|
1087
1148
|
function include (val, msg) {
|
|
1088
1149
|
if (msg) flag(this, 'message', msg);
|
|
1089
|
-
var obj = flag(this, 'object')
|
|
1150
|
+
var obj = flag(this, 'object');
|
|
1151
|
+
var expected = false;
|
|
1152
|
+
if (_.type(obj) === 'array' && _.type(val) === 'object') {
|
|
1153
|
+
for (var i in obj) {
|
|
1154
|
+
if (_.eql(obj[i], val)) {
|
|
1155
|
+
expected = true;
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} else if (_.type(val) === 'object') {
|
|
1160
|
+
if (!flag(this, 'negate')) {
|
|
1161
|
+
for (var k in val) new Assertion(obj).property(k, val[k]);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
var subset = {}
|
|
1165
|
+
for (var k in val) subset[k] = obj[k]
|
|
1166
|
+
expected = _.eql(subset, val);
|
|
1167
|
+
} else {
|
|
1168
|
+
expected = obj && ~obj.indexOf(val)
|
|
1169
|
+
}
|
|
1090
1170
|
this.assert(
|
|
1091
|
-
|
|
1171
|
+
expected
|
|
1092
1172
|
, 'expected #{this} to include ' + _.inspect(val)
|
|
1093
1173
|
, 'expected #{this} to not include ' + _.inspect(val));
|
|
1094
1174
|
}
|
|
@@ -1792,7 +1872,7 @@ module.exports = function (chai, _) {
|
|
|
1792
1872
|
}
|
|
1793
1873
|
|
|
1794
1874
|
Assertion.addChainableMethod('length', assertLength, assertLengthChain);
|
|
1795
|
-
Assertion.addMethod('lengthOf', assertLength
|
|
1875
|
+
Assertion.addMethod('lengthOf', assertLength);
|
|
1796
1876
|
|
|
1797
1877
|
/**
|
|
1798
1878
|
* ### .match(regexp)
|
|
@@ -1871,6 +1951,7 @@ module.exports = function (chai, _) {
|
|
|
1871
1951
|
if (!keys.length) throw new Error('keys required');
|
|
1872
1952
|
|
|
1873
1953
|
var actual = Object.keys(obj)
|
|
1954
|
+
, expected = keys
|
|
1874
1955
|
, len = keys.length;
|
|
1875
1956
|
|
|
1876
1957
|
// Inclusion
|
|
@@ -1905,6 +1986,9 @@ module.exports = function (chai, _) {
|
|
|
1905
1986
|
ok
|
|
1906
1987
|
, 'expected #{this} to ' + str
|
|
1907
1988
|
, 'expected #{this} to not ' + str
|
|
1989
|
+
, expected.sort()
|
|
1990
|
+
, actual.sort()
|
|
1991
|
+
, true
|
|
1908
1992
|
);
|
|
1909
1993
|
}
|
|
1910
1994
|
|
|
@@ -1943,6 +2027,7 @@ module.exports = function (chai, _) {
|
|
|
1943
2027
|
* @param {String|RegExp} expected error message
|
|
1944
2028
|
* @param {String} message _optional_
|
|
1945
2029
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
2030
|
+
* @returns error for chaining (null if no error)
|
|
1946
2031
|
* @api public
|
|
1947
2032
|
*/
|
|
1948
2033
|
|
|
@@ -1967,7 +2052,10 @@ module.exports = function (chai, _) {
|
|
|
1967
2052
|
constructor = null;
|
|
1968
2053
|
errMsg = null;
|
|
1969
2054
|
} else if (typeof constructor === 'function') {
|
|
1970
|
-
name =
|
|
2055
|
+
name = constructor.prototype.name || constructor.name;
|
|
2056
|
+
if (name === 'Error' && constructor !== Error) {
|
|
2057
|
+
name = (new constructor()).name;
|
|
2058
|
+
}
|
|
1971
2059
|
} else {
|
|
1972
2060
|
constructor = null;
|
|
1973
2061
|
}
|
|
@@ -1981,12 +2069,14 @@ module.exports = function (chai, _) {
|
|
|
1981
2069
|
err === desiredError
|
|
1982
2070
|
, 'expected #{this} to throw #{exp} but #{act} was thrown'
|
|
1983
2071
|
, 'expected #{this} to not throw #{exp}'
|
|
1984
|
-
, desiredError
|
|
1985
|
-
, err
|
|
2072
|
+
, (desiredError instanceof Error ? desiredError.toString() : desiredError)
|
|
2073
|
+
, (err instanceof Error ? err.toString() : err)
|
|
1986
2074
|
);
|
|
1987
2075
|
|
|
2076
|
+
flag(this, 'object', err);
|
|
1988
2077
|
return this;
|
|
1989
2078
|
}
|
|
2079
|
+
|
|
1990
2080
|
// next, check constructor
|
|
1991
2081
|
if (constructor) {
|
|
1992
2082
|
this.assert(
|
|
@@ -1994,11 +2084,15 @@ module.exports = function (chai, _) {
|
|
|
1994
2084
|
, 'expected #{this} to throw #{exp} but #{act} was thrown'
|
|
1995
2085
|
, 'expected #{this} to not throw #{exp} but #{act} was thrown'
|
|
1996
2086
|
, name
|
|
1997
|
-
, err
|
|
2087
|
+
, (err instanceof Error ? err.toString() : err)
|
|
1998
2088
|
);
|
|
1999
2089
|
|
|
2000
|
-
if (!errMsg)
|
|
2090
|
+
if (!errMsg) {
|
|
2091
|
+
flag(this, 'object', err);
|
|
2092
|
+
return this;
|
|
2093
|
+
}
|
|
2001
2094
|
}
|
|
2095
|
+
|
|
2002
2096
|
// next, check message
|
|
2003
2097
|
var message = 'object' === _.type(err) && "message" in err
|
|
2004
2098
|
? err.message
|
|
@@ -2013,6 +2107,7 @@ module.exports = function (chai, _) {
|
|
|
2013
2107
|
, message
|
|
2014
2108
|
);
|
|
2015
2109
|
|
|
2110
|
+
flag(this, 'object', err);
|
|
2016
2111
|
return this;
|
|
2017
2112
|
} else if ((message != null) && errMsg && 'string' === typeof errMsg) {
|
|
2018
2113
|
this.assert(
|
|
@@ -2023,6 +2118,7 @@ module.exports = function (chai, _) {
|
|
|
2023
2118
|
, message
|
|
2024
2119
|
);
|
|
2025
2120
|
|
|
2121
|
+
flag(this, 'object', err);
|
|
2026
2122
|
return this;
|
|
2027
2123
|
} else {
|
|
2028
2124
|
thrown = true;
|
|
@@ -2045,9 +2141,11 @@ module.exports = function (chai, _) {
|
|
|
2045
2141
|
thrown === true
|
|
2046
2142
|
, 'expected #{this} to throw ' + expectedThrown + actuallyGot
|
|
2047
2143
|
, 'expected #{this} to not throw ' + expectedThrown + actuallyGot
|
|
2048
|
-
, desiredError
|
|
2049
|
-
, thrownError
|
|
2144
|
+
, (desiredError instanceof Error ? desiredError.toString() : desiredError)
|
|
2145
|
+
, (thrownError instanceof Error ? thrownError.toString() : thrownError)
|
|
2050
2146
|
);
|
|
2147
|
+
|
|
2148
|
+
flag(this, 'object', thrownError);
|
|
2051
2149
|
};
|
|
2052
2150
|
|
|
2053
2151
|
Assertion.addMethod('throw', assertThrows);
|
|
@@ -2126,12 +2224,13 @@ module.exports = function (chai, _) {
|
|
|
2126
2224
|
Assertion.addMethod('satisfy', function (matcher, msg) {
|
|
2127
2225
|
if (msg) flag(this, 'message', msg);
|
|
2128
2226
|
var obj = flag(this, 'object');
|
|
2227
|
+
var result = matcher(obj);
|
|
2129
2228
|
this.assert(
|
|
2130
|
-
|
|
2229
|
+
result
|
|
2131
2230
|
, 'expected #{this} to satisfy ' + _.objDisplay(matcher)
|
|
2132
2231
|
, 'expected #{this} to not satisfy' + _.objDisplay(matcher)
|
|
2133
2232
|
, this.negate ? false : true
|
|
2134
|
-
,
|
|
2233
|
+
, result
|
|
2135
2234
|
);
|
|
2136
2235
|
});
|
|
2137
2236
|
|
|
@@ -2152,6 +2251,12 @@ module.exports = function (chai, _) {
|
|
|
2152
2251
|
Assertion.addMethod('closeTo', function (expected, delta, msg) {
|
|
2153
2252
|
if (msg) flag(this, 'message', msg);
|
|
2154
2253
|
var obj = flag(this, 'object');
|
|
2254
|
+
|
|
2255
|
+
new Assertion(obj, msg).is.a('number');
|
|
2256
|
+
if (_.type(expected) !== 'number' || _.type(delta) !== 'number') {
|
|
2257
|
+
throw new Error('the arguments to closeTo must be numbers');
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2155
2260
|
this.assert(
|
|
2156
2261
|
Math.abs(obj - expected) <= delta
|
|
2157
2262
|
, 'expected #{this} to be close to ' + expected + ' +/- ' + delta
|
|
@@ -2159,9 +2264,13 @@ module.exports = function (chai, _) {
|
|
|
2159
2264
|
);
|
|
2160
2265
|
});
|
|
2161
2266
|
|
|
2162
|
-
function isSubsetOf(subset, superset) {
|
|
2267
|
+
function isSubsetOf(subset, superset, cmp) {
|
|
2163
2268
|
return subset.every(function(elem) {
|
|
2164
|
-
return superset.indexOf(elem) !== -1;
|
|
2269
|
+
if (!cmp) return superset.indexOf(elem) !== -1;
|
|
2270
|
+
|
|
2271
|
+
return superset.some(function(elem2) {
|
|
2272
|
+
return cmp(elem, elem2);
|
|
2273
|
+
});
|
|
2165
2274
|
})
|
|
2166
2275
|
}
|
|
2167
2276
|
|
|
@@ -2169,7 +2278,9 @@ module.exports = function (chai, _) {
|
|
|
2169
2278
|
* ### .members(set)
|
|
2170
2279
|
*
|
|
2171
2280
|
* Asserts that the target is a superset of `set`,
|
|
2172
|
-
* or that the target and `set` have the same members.
|
|
2281
|
+
* or that the target and `set` have the same strictly-equal (===) members.
|
|
2282
|
+
* Alternately, if the `deep` flag is set, set members are compared for deep
|
|
2283
|
+
* equality.
|
|
2173
2284
|
*
|
|
2174
2285
|
* expect([1, 2, 3]).to.include.members([3, 2]);
|
|
2175
2286
|
* expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
|
|
@@ -2177,6 +2288,8 @@ module.exports = function (chai, _) {
|
|
|
2177
2288
|
* expect([4, 2]).to.have.members([2, 4]);
|
|
2178
2289
|
* expect([5, 2]).to.not.have.members([5, 2, 1]);
|
|
2179
2290
|
*
|
|
2291
|
+
* expect([{ id: 1 }]).to.deep.include.members([{ id: 1 }]);
|
|
2292
|
+
*
|
|
2180
2293
|
* @name members
|
|
2181
2294
|
* @param {Array} set
|
|
2182
2295
|
* @param {String} message _optional_
|
|
@@ -2190,9 +2303,11 @@ module.exports = function (chai, _) {
|
|
|
2190
2303
|
new Assertion(obj).to.be.an('array');
|
|
2191
2304
|
new Assertion(subset).to.be.an('array');
|
|
2192
2305
|
|
|
2306
|
+
var cmp = flag(this, 'deep') ? _.eql : undefined;
|
|
2307
|
+
|
|
2193
2308
|
if (flag(this, 'contains')) {
|
|
2194
2309
|
return this.assert(
|
|
2195
|
-
isSubsetOf(subset, obj)
|
|
2310
|
+
isSubsetOf(subset, obj, cmp)
|
|
2196
2311
|
, 'expected #{this} to be a superset of #{act}'
|
|
2197
2312
|
, 'expected #{this} to not be a superset of #{act}'
|
|
2198
2313
|
, obj
|
|
@@ -2201,7 +2316,7 @@ module.exports = function (chai, _) {
|
|
|
2201
2316
|
}
|
|
2202
2317
|
|
|
2203
2318
|
this.assert(
|
|
2204
|
-
isSubsetOf(obj, subset) && isSubsetOf(subset, obj)
|
|
2319
|
+
isSubsetOf(obj, subset, cmp) && isSubsetOf(subset, obj, cmp)
|
|
2205
2320
|
, 'expected #{this} to have the same members as #{act}'
|
|
2206
2321
|
, 'expected #{this} to not have the same members as #{act}'
|
|
2207
2322
|
, obj
|
|
@@ -2214,7 +2329,7 @@ module.exports = function (chai, _) {
|
|
|
2214
2329
|
require.register("chai/lib/chai/interface/assert.js", function(exports, require, module){
|
|
2215
2330
|
/*!
|
|
2216
2331
|
* chai
|
|
2217
|
-
* Copyright(c) 2011-
|
|
2332
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
2218
2333
|
* MIT Licensed
|
|
2219
2334
|
*/
|
|
2220
2335
|
|
|
@@ -2247,7 +2362,7 @@ module.exports = function (chai, util) {
|
|
|
2247
2362
|
*/
|
|
2248
2363
|
|
|
2249
2364
|
var assert = chai.assert = function (express, errmsg) {
|
|
2250
|
-
var test = new Assertion(null);
|
|
2365
|
+
var test = new Assertion(null, null, chai.assert);
|
|
2251
2366
|
test.assert(
|
|
2252
2367
|
express
|
|
2253
2368
|
, errmsg
|
|
@@ -2269,13 +2384,12 @@ module.exports = function (chai, util) {
|
|
|
2269
2384
|
*/
|
|
2270
2385
|
|
|
2271
2386
|
assert.fail = function (actual, expected, message, operator) {
|
|
2272
|
-
|
|
2387
|
+
message = message || 'assert.fail()';
|
|
2388
|
+
throw new chai.AssertionError(message, {
|
|
2273
2389
|
actual: actual
|
|
2274
2390
|
, expected: expected
|
|
2275
|
-
, message: message
|
|
2276
2391
|
, operator: operator
|
|
2277
|
-
|
|
2278
|
-
});
|
|
2392
|
+
}, assert.fail);
|
|
2279
2393
|
};
|
|
2280
2394
|
|
|
2281
2395
|
/**
|
|
@@ -2329,7 +2443,7 @@ module.exports = function (chai, util) {
|
|
|
2329
2443
|
*/
|
|
2330
2444
|
|
|
2331
2445
|
assert.equal = function (act, exp, msg) {
|
|
2332
|
-
var test = new Assertion(act, msg);
|
|
2446
|
+
var test = new Assertion(act, msg, assert.equal);
|
|
2333
2447
|
|
|
2334
2448
|
test.assert(
|
|
2335
2449
|
exp == flag(test, 'object')
|
|
@@ -2355,7 +2469,7 @@ module.exports = function (chai, util) {
|
|
|
2355
2469
|
*/
|
|
2356
2470
|
|
|
2357
2471
|
assert.notEqual = function (act, exp, msg) {
|
|
2358
|
-
var test = new Assertion(act, msg);
|
|
2472
|
+
var test = new Assertion(act, msg, assert.notEqual);
|
|
2359
2473
|
|
|
2360
2474
|
test.assert(
|
|
2361
2475
|
exp != flag(test, 'object')
|
|
@@ -2606,8 +2720,8 @@ module.exports = function (chai, util) {
|
|
|
2606
2720
|
* Asserts that `value` is _not_ an object.
|
|
2607
2721
|
*
|
|
2608
2722
|
* var selection = 'chai'
|
|
2609
|
-
* assert.
|
|
2610
|
-
* assert.
|
|
2723
|
+
* assert.isNotObject(selection, 'tea selection is not an object');
|
|
2724
|
+
* assert.isNotObject(null, 'null is not an object');
|
|
2611
2725
|
*
|
|
2612
2726
|
* @name isNotObject
|
|
2613
2727
|
* @param {Mixed} value
|
|
@@ -2871,19 +2985,7 @@ module.exports = function (chai, util) {
|
|
|
2871
2985
|
*/
|
|
2872
2986
|
|
|
2873
2987
|
assert.include = function (exp, inc, msg) {
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
if (Array.isArray(exp)) {
|
|
2877
|
-
obj.to.include(inc);
|
|
2878
|
-
} else if ('string' === typeof exp) {
|
|
2879
|
-
obj.to.contain.string(inc);
|
|
2880
|
-
} else {
|
|
2881
|
-
throw new chai.AssertionError(
|
|
2882
|
-
'expected an array or string'
|
|
2883
|
-
, null
|
|
2884
|
-
, assert.include
|
|
2885
|
-
);
|
|
2886
|
-
}
|
|
2988
|
+
new Assertion(exp, msg, assert.include).include(inc);
|
|
2887
2989
|
};
|
|
2888
2990
|
|
|
2889
2991
|
/**
|
|
@@ -2903,19 +3005,7 @@ module.exports = function (chai, util) {
|
|
|
2903
3005
|
*/
|
|
2904
3006
|
|
|
2905
3007
|
assert.notInclude = function (exp, inc, msg) {
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
if (Array.isArray(exp)) {
|
|
2909
|
-
obj.to.not.include(inc);
|
|
2910
|
-
} else if ('string' === typeof exp) {
|
|
2911
|
-
obj.to.not.contain.string(inc);
|
|
2912
|
-
} else {
|
|
2913
|
-
throw new chai.AssertionError(
|
|
2914
|
-
'expected an array or string'
|
|
2915
|
-
, null
|
|
2916
|
-
, assert.notInclude
|
|
2917
|
-
);
|
|
2918
|
-
}
|
|
3008
|
+
new Assertion(exp, msg, assert.notInclude).not.include(inc);
|
|
2919
3009
|
};
|
|
2920
3010
|
|
|
2921
3011
|
/**
|
|
@@ -3159,7 +3249,8 @@ module.exports = function (chai, util) {
|
|
|
3159
3249
|
errt = null;
|
|
3160
3250
|
}
|
|
3161
3251
|
|
|
3162
|
-
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
3252
|
+
var assertErr = new Assertion(fn, msg).to.Throw(errt, errs);
|
|
3253
|
+
return flag(assertErr, 'object');
|
|
3163
3254
|
};
|
|
3164
3255
|
|
|
3165
3256
|
/**
|
|
@@ -3244,8 +3335,8 @@ module.exports = function (chai, util) {
|
|
|
3244
3335
|
* assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
|
|
3245
3336
|
*
|
|
3246
3337
|
* @name sameMembers
|
|
3247
|
-
* @param {Array}
|
|
3248
|
-
* @param {Array}
|
|
3338
|
+
* @param {Array} set1
|
|
3339
|
+
* @param {Array} set2
|
|
3249
3340
|
* @param {String} message
|
|
3250
3341
|
* @api public
|
|
3251
3342
|
*/
|
|
@@ -3297,7 +3388,7 @@ module.exports = function (chai, util) {
|
|
|
3297
3388
|
require.register("chai/lib/chai/interface/expect.js", function(exports, require, module){
|
|
3298
3389
|
/*!
|
|
3299
3390
|
* chai
|
|
3300
|
-
* Copyright(c) 2011-
|
|
3391
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3301
3392
|
* MIT Licensed
|
|
3302
3393
|
*/
|
|
3303
3394
|
|
|
@@ -3312,7 +3403,7 @@ module.exports = function (chai, util) {
|
|
|
3312
3403
|
require.register("chai/lib/chai/interface/should.js", function(exports, require, module){
|
|
3313
3404
|
/*!
|
|
3314
3405
|
* chai
|
|
3315
|
-
* Copyright(c) 2011-
|
|
3406
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3316
3407
|
* MIT Licensed
|
|
3317
3408
|
*/
|
|
3318
3409
|
|
|
@@ -3320,31 +3411,33 @@ module.exports = function (chai, util) {
|
|
|
3320
3411
|
var Assertion = chai.Assertion;
|
|
3321
3412
|
|
|
3322
3413
|
function loadShould () {
|
|
3414
|
+
// explicitly define this method as function as to have it's name to include as `ssfi`
|
|
3415
|
+
function shouldGetter() {
|
|
3416
|
+
if (this instanceof String || this instanceof Number) {
|
|
3417
|
+
return new Assertion(this.constructor(this), null, shouldGetter);
|
|
3418
|
+
} else if (this instanceof Boolean) {
|
|
3419
|
+
return new Assertion(this == true, null, shouldGetter);
|
|
3420
|
+
}
|
|
3421
|
+
return new Assertion(this, null, shouldGetter);
|
|
3422
|
+
}
|
|
3423
|
+
function shouldSetter(value) {
|
|
3424
|
+
// See https://github.com/chaijs/chai/issues/86: this makes
|
|
3425
|
+
// `whatever.should = someValue` actually set `someValue`, which is
|
|
3426
|
+
// especially useful for `global.should = require('chai').should()`.
|
|
3427
|
+
//
|
|
3428
|
+
// Note that we have to use [[DefineProperty]] instead of [[Put]]
|
|
3429
|
+
// since otherwise we would trigger this very setter!
|
|
3430
|
+
Object.defineProperty(this, 'should', {
|
|
3431
|
+
value: value,
|
|
3432
|
+
enumerable: true,
|
|
3433
|
+
configurable: true,
|
|
3434
|
+
writable: true
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3323
3437
|
// modify Object.prototype to have `should`
|
|
3324
|
-
Object.defineProperty(Object.prototype, 'should',
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
// See https://github.com/chaijs/chai/issues/86: this makes
|
|
3328
|
-
// `whatever.should = someValue` actually set `someValue`, which is
|
|
3329
|
-
// especially useful for `global.should = require('chai').should()`.
|
|
3330
|
-
//
|
|
3331
|
-
// Note that we have to use [[DefineProperty]] instead of [[Put]]
|
|
3332
|
-
// since otherwise we would trigger this very setter!
|
|
3333
|
-
Object.defineProperty(this, 'should', {
|
|
3334
|
-
value: value,
|
|
3335
|
-
enumerable: true,
|
|
3336
|
-
configurable: true,
|
|
3337
|
-
writable: true
|
|
3338
|
-
});
|
|
3339
|
-
}
|
|
3340
|
-
, get: function(){
|
|
3341
|
-
if (this instanceof String || this instanceof Number) {
|
|
3342
|
-
return new Assertion(this.constructor(this));
|
|
3343
|
-
} else if (this instanceof Boolean) {
|
|
3344
|
-
return new Assertion(this == true);
|
|
3345
|
-
}
|
|
3346
|
-
return new Assertion(this);
|
|
3347
|
-
}
|
|
3438
|
+
Object.defineProperty(Object.prototype, 'should', {
|
|
3439
|
+
set: shouldSetter
|
|
3440
|
+
, get: shouldGetter
|
|
3348
3441
|
, configurable: true
|
|
3349
3442
|
});
|
|
3350
3443
|
|
|
@@ -3391,7 +3484,7 @@ module.exports = function (chai, util) {
|
|
|
3391
3484
|
require.register("chai/lib/chai/utils/addChainableMethod.js", function(exports, require, module){
|
|
3392
3485
|
/*!
|
|
3393
3486
|
* Chai - addChainingMethod utility
|
|
3394
|
-
* Copyright(c) 2012-
|
|
3487
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3395
3488
|
* MIT Licensed
|
|
3396
3489
|
*/
|
|
3397
3490
|
|
|
@@ -3400,6 +3493,8 @@ require.register("chai/lib/chai/utils/addChainableMethod.js", function(exports,
|
|
|
3400
3493
|
*/
|
|
3401
3494
|
|
|
3402
3495
|
var transferFlags = require('./transferFlags');
|
|
3496
|
+
var flag = require('./flag');
|
|
3497
|
+
var config = require('../config');
|
|
3403
3498
|
|
|
3404
3499
|
/*!
|
|
3405
3500
|
* Module variables
|
|
@@ -3446,15 +3541,30 @@ var call = Function.prototype.call,
|
|
|
3446
3541
|
*/
|
|
3447
3542
|
|
|
3448
3543
|
module.exports = function (ctx, name, method, chainingBehavior) {
|
|
3449
|
-
if (typeof chainingBehavior !== 'function')
|
|
3544
|
+
if (typeof chainingBehavior !== 'function') {
|
|
3450
3545
|
chainingBehavior = function () { };
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
var chainableBehavior = {
|
|
3549
|
+
method: method
|
|
3550
|
+
, chainingBehavior: chainingBehavior
|
|
3551
|
+
};
|
|
3552
|
+
|
|
3553
|
+
// save the methods so we can overwrite them later, if we need to.
|
|
3554
|
+
if (!ctx.__methods) {
|
|
3555
|
+
ctx.__methods = {};
|
|
3556
|
+
}
|
|
3557
|
+
ctx.__methods[name] = chainableBehavior;
|
|
3451
3558
|
|
|
3452
3559
|
Object.defineProperty(ctx, name,
|
|
3453
3560
|
{ get: function () {
|
|
3454
|
-
chainingBehavior.call(this);
|
|
3561
|
+
chainableBehavior.chainingBehavior.call(this);
|
|
3455
3562
|
|
|
3456
|
-
var assert = function () {
|
|
3457
|
-
var
|
|
3563
|
+
var assert = function assert() {
|
|
3564
|
+
var old_ssfi = flag(this, 'ssfi');
|
|
3565
|
+
if (old_ssfi && config.includeStack === false)
|
|
3566
|
+
flag(this, 'ssfi', assert);
|
|
3567
|
+
var result = chainableBehavior.method.apply(this, arguments);
|
|
3458
3568
|
return result === undefined ? this : result;
|
|
3459
3569
|
};
|
|
3460
3570
|
|
|
@@ -3488,10 +3598,12 @@ module.exports = function (ctx, name, method, chainingBehavior) {
|
|
|
3488
3598
|
require.register("chai/lib/chai/utils/addMethod.js", function(exports, require, module){
|
|
3489
3599
|
/*!
|
|
3490
3600
|
* Chai - addMethod utility
|
|
3491
|
-
* Copyright(c) 2012-
|
|
3601
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3492
3602
|
* MIT Licensed
|
|
3493
3603
|
*/
|
|
3494
3604
|
|
|
3605
|
+
var config = require('../config');
|
|
3606
|
+
|
|
3495
3607
|
/**
|
|
3496
3608
|
* ### .addMethod (ctx, name, method)
|
|
3497
3609
|
*
|
|
@@ -3516,9 +3628,13 @@ require.register("chai/lib/chai/utils/addMethod.js", function(exports, require,
|
|
|
3516
3628
|
* @name addMethod
|
|
3517
3629
|
* @api public
|
|
3518
3630
|
*/
|
|
3631
|
+
var flag = require('./flag');
|
|
3519
3632
|
|
|
3520
3633
|
module.exports = function (ctx, name, method) {
|
|
3521
3634
|
ctx[name] = function () {
|
|
3635
|
+
var old_ssfi = flag(this, 'ssfi');
|
|
3636
|
+
if (old_ssfi && config.includeStack === false)
|
|
3637
|
+
flag(this, 'ssfi', ctx[name]);
|
|
3522
3638
|
var result = method.apply(this, arguments);
|
|
3523
3639
|
return result === undefined ? this : result;
|
|
3524
3640
|
};
|
|
@@ -3528,7 +3644,7 @@ module.exports = function (ctx, name, method) {
|
|
|
3528
3644
|
require.register("chai/lib/chai/utils/addProperty.js", function(exports, require, module){
|
|
3529
3645
|
/*!
|
|
3530
3646
|
* Chai - addProperty utility
|
|
3531
|
-
* Copyright(c) 2012-
|
|
3647
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3532
3648
|
* MIT Licensed
|
|
3533
3649
|
*/
|
|
3534
3650
|
|
|
@@ -3571,7 +3687,7 @@ module.exports = function (ctx, name, getter) {
|
|
|
3571
3687
|
require.register("chai/lib/chai/utils/flag.js", function(exports, require, module){
|
|
3572
3688
|
/*!
|
|
3573
3689
|
* Chai - flag utility
|
|
3574
|
-
* Copyright(c) 2012-
|
|
3690
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3575
3691
|
* MIT Licensed
|
|
3576
3692
|
*/
|
|
3577
3693
|
|
|
@@ -3606,7 +3722,7 @@ module.exports = function (obj, key, value) {
|
|
|
3606
3722
|
require.register("chai/lib/chai/utils/getActual.js", function(exports, require, module){
|
|
3607
3723
|
/*!
|
|
3608
3724
|
* Chai - getActual utility
|
|
3609
|
-
* Copyright(c) 2012-
|
|
3725
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3610
3726
|
* MIT Licensed
|
|
3611
3727
|
*/
|
|
3612
3728
|
|
|
@@ -3620,15 +3736,14 @@ require.register("chai/lib/chai/utils/getActual.js", function(exports, require,
|
|
|
3620
3736
|
*/
|
|
3621
3737
|
|
|
3622
3738
|
module.exports = function (obj, args) {
|
|
3623
|
-
|
|
3624
|
-
return 'undefined' !== typeof actual ? actual : obj._obj;
|
|
3739
|
+
return args.length > 4 ? args[4] : obj._obj;
|
|
3625
3740
|
};
|
|
3626
3741
|
|
|
3627
3742
|
});
|
|
3628
3743
|
require.register("chai/lib/chai/utils/getEnumerableProperties.js", function(exports, require, module){
|
|
3629
3744
|
/*!
|
|
3630
3745
|
* Chai - getEnumerableProperties utility
|
|
3631
|
-
* Copyright(c) 2012-
|
|
3746
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3632
3747
|
* MIT Licensed
|
|
3633
3748
|
*/
|
|
3634
3749
|
|
|
@@ -3656,7 +3771,7 @@ module.exports = function getEnumerableProperties(object) {
|
|
|
3656
3771
|
require.register("chai/lib/chai/utils/getMessage.js", function(exports, require, module){
|
|
3657
3772
|
/*!
|
|
3658
3773
|
* Chai - message composition utility
|
|
3659
|
-
* Copyright(c) 2012-
|
|
3774
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3660
3775
|
* MIT Licensed
|
|
3661
3776
|
*/
|
|
3662
3777
|
|
|
@@ -3695,6 +3810,7 @@ module.exports = function (obj, args) {
|
|
|
3695
3810
|
, msg = negate ? args[2] : args[1]
|
|
3696
3811
|
, flagMsg = flag(obj, 'message');
|
|
3697
3812
|
|
|
3813
|
+
if(typeof msg === "function") msg = msg();
|
|
3698
3814
|
msg = msg || '';
|
|
3699
3815
|
msg = msg
|
|
3700
3816
|
.replace(/#{this}/g, objDisplay(val))
|
|
@@ -3708,7 +3824,7 @@ module.exports = function (obj, args) {
|
|
|
3708
3824
|
require.register("chai/lib/chai/utils/getName.js", function(exports, require, module){
|
|
3709
3825
|
/*!
|
|
3710
3826
|
* Chai - getName utility
|
|
3711
|
-
* Copyright(c) 2012-
|
|
3827
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3712
3828
|
* MIT Licensed
|
|
3713
3829
|
*/
|
|
3714
3830
|
|
|
@@ -3731,7 +3847,7 @@ module.exports = function (func) {
|
|
|
3731
3847
|
require.register("chai/lib/chai/utils/getPathValue.js", function(exports, require, module){
|
|
3732
3848
|
/*!
|
|
3733
3849
|
* Chai - getPathValue utility
|
|
3734
|
-
* Copyright(c) 2012-
|
|
3850
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3735
3851
|
* @see https://github.com/logicalparadox/filtr
|
|
3736
3852
|
* MIT Licensed
|
|
3737
3853
|
*/
|
|
@@ -3836,7 +3952,7 @@ function _getPathValue (parsed, obj) {
|
|
|
3836
3952
|
require.register("chai/lib/chai/utils/getProperties.js", function(exports, require, module){
|
|
3837
3953
|
/*!
|
|
3838
3954
|
* Chai - getProperties utility
|
|
3839
|
-
* Copyright(c) 2012-
|
|
3955
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
3840
3956
|
* MIT Licensed
|
|
3841
3957
|
*/
|
|
3842
3958
|
|
|
@@ -3980,6 +4096,12 @@ exports.overwriteMethod = require('./overwriteMethod');
|
|
|
3980
4096
|
|
|
3981
4097
|
exports.addChainableMethod = require('./addChainableMethod');
|
|
3982
4098
|
|
|
4099
|
+
/*!
|
|
4100
|
+
* Overwrite chainable method
|
|
4101
|
+
*/
|
|
4102
|
+
|
|
4103
|
+
exports.overwriteChainableMethod = require('./overwriteChainableMethod');
|
|
4104
|
+
|
|
3983
4105
|
|
|
3984
4106
|
});
|
|
3985
4107
|
require.register("chai/lib/chai/utils/inspect.js", function(exports, require, module){
|
|
@@ -4012,24 +4134,6 @@ function inspect(obj, showHidden, depth, colors) {
|
|
|
4012
4134
|
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
|
4013
4135
|
}
|
|
4014
4136
|
|
|
4015
|
-
// https://gist.github.com/1044128/
|
|
4016
|
-
var getOuterHTML = function(element) {
|
|
4017
|
-
if ('outerHTML' in element) return element.outerHTML;
|
|
4018
|
-
var ns = "http://www.w3.org/1999/xhtml";
|
|
4019
|
-
var container = document.createElementNS(ns, '_');
|
|
4020
|
-
var elemProto = (window.HTMLElement || window.Element).prototype;
|
|
4021
|
-
var xmlSerializer = new XMLSerializer();
|
|
4022
|
-
var html;
|
|
4023
|
-
if (document.xmlVersion) {
|
|
4024
|
-
return xmlSerializer.serializeToString(element);
|
|
4025
|
-
} else {
|
|
4026
|
-
container.appendChild(element.cloneNode(false));
|
|
4027
|
-
html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
|
|
4028
|
-
container.innerHTML = '';
|
|
4029
|
-
return html;
|
|
4030
|
-
}
|
|
4031
|
-
};
|
|
4032
|
-
|
|
4033
4137
|
// Returns true if object is a DOM element.
|
|
4034
4138
|
var isDOMElement = function (object) {
|
|
4035
4139
|
if (typeof HTMLElement === 'object') {
|
|
@@ -4063,9 +4167,37 @@ function formatValue(ctx, value, recurseTimes) {
|
|
|
4063
4167
|
return primitive;
|
|
4064
4168
|
}
|
|
4065
4169
|
|
|
4066
|
-
// If
|
|
4170
|
+
// If this is a DOM element, try to get the outer HTML.
|
|
4067
4171
|
if (isDOMElement(value)) {
|
|
4068
|
-
|
|
4172
|
+
if ('outerHTML' in value) {
|
|
4173
|
+
return value.outerHTML;
|
|
4174
|
+
// This value does not have an outerHTML attribute,
|
|
4175
|
+
// it could still be an XML element
|
|
4176
|
+
} else {
|
|
4177
|
+
// Attempt to serialize it
|
|
4178
|
+
try {
|
|
4179
|
+
if (document.xmlVersion) {
|
|
4180
|
+
var xmlSerializer = new XMLSerializer();
|
|
4181
|
+
return xmlSerializer.serializeToString(value);
|
|
4182
|
+
} else {
|
|
4183
|
+
// Firefox 11- do not support outerHTML
|
|
4184
|
+
// It does, however, support innerHTML
|
|
4185
|
+
// Use the following to render the element
|
|
4186
|
+
var ns = "http://www.w3.org/1999/xhtml";
|
|
4187
|
+
var container = document.createElementNS(ns, '_');
|
|
4188
|
+
|
|
4189
|
+
container.appendChild(value.cloneNode(false));
|
|
4190
|
+
html = container.innerHTML
|
|
4191
|
+
.replace('><', '>' + value.innerHTML + '<');
|
|
4192
|
+
container.innerHTML = '';
|
|
4193
|
+
return html;
|
|
4194
|
+
}
|
|
4195
|
+
} catch (err) {
|
|
4196
|
+
// This could be a non-native DOM implementation,
|
|
4197
|
+
// continue with the normal flow:
|
|
4198
|
+
// printing the element as if it is an object.
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4069
4201
|
}
|
|
4070
4202
|
|
|
4071
4203
|
// Look up the keys of the object.
|
|
@@ -4308,7 +4440,7 @@ function objectToString(o) {
|
|
|
4308
4440
|
require.register("chai/lib/chai/utils/objDisplay.js", function(exports, require, module){
|
|
4309
4441
|
/*!
|
|
4310
4442
|
* Chai - flag utility
|
|
4311
|
-
* Copyright(c) 2012-
|
|
4443
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4312
4444
|
* MIT Licensed
|
|
4313
4445
|
*/
|
|
4314
4446
|
|
|
@@ -4317,6 +4449,7 @@ require.register("chai/lib/chai/utils/objDisplay.js", function(exports, require,
|
|
|
4317
4449
|
*/
|
|
4318
4450
|
|
|
4319
4451
|
var inspect = require('./inspect');
|
|
4452
|
+
var config = require('../config');
|
|
4320
4453
|
|
|
4321
4454
|
/**
|
|
4322
4455
|
* ### .objDisplay (object)
|
|
@@ -4334,7 +4467,7 @@ module.exports = function (obj) {
|
|
|
4334
4467
|
var str = inspect(obj)
|
|
4335
4468
|
, type = Object.prototype.toString.call(obj);
|
|
4336
4469
|
|
|
4337
|
-
if (str.length >=
|
|
4470
|
+
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
|
4338
4471
|
if (type === '[object Function]') {
|
|
4339
4472
|
return !obj.name || obj.name === ''
|
|
4340
4473
|
? '[Function]'
|
|
@@ -4359,7 +4492,7 @@ module.exports = function (obj) {
|
|
|
4359
4492
|
require.register("chai/lib/chai/utils/overwriteMethod.js", function(exports, require, module){
|
|
4360
4493
|
/*!
|
|
4361
4494
|
* Chai - overwriteMethod utility
|
|
4362
|
-
* Copyright(c) 2012-
|
|
4495
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4363
4496
|
* MIT Licensed
|
|
4364
4497
|
*/
|
|
4365
4498
|
|
|
@@ -4413,7 +4546,7 @@ module.exports = function (ctx, name, method) {
|
|
|
4413
4546
|
require.register("chai/lib/chai/utils/overwriteProperty.js", function(exports, require, module){
|
|
4414
4547
|
/*!
|
|
4415
4548
|
* Chai - overwriteProperty utility
|
|
4416
|
-
* Copyright(c) 2012-
|
|
4549
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4417
4550
|
* MIT Licensed
|
|
4418
4551
|
*/
|
|
4419
4552
|
|
|
@@ -4466,11 +4599,67 @@ module.exports = function (ctx, name, getter) {
|
|
|
4466
4599
|
});
|
|
4467
4600
|
};
|
|
4468
4601
|
|
|
4602
|
+
});
|
|
4603
|
+
require.register("chai/lib/chai/utils/overwriteChainableMethod.js", function(exports, require, module){
|
|
4604
|
+
/*!
|
|
4605
|
+
* Chai - overwriteChainableMethod utility
|
|
4606
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4607
|
+
* MIT Licensed
|
|
4608
|
+
*/
|
|
4609
|
+
|
|
4610
|
+
/**
|
|
4611
|
+
* ### overwriteChainableMethod (ctx, name, fn)
|
|
4612
|
+
*
|
|
4613
|
+
* Overwites an already existing chainable method
|
|
4614
|
+
* and provides access to the previous function or
|
|
4615
|
+
* property. Must return functions to be used for
|
|
4616
|
+
* name.
|
|
4617
|
+
*
|
|
4618
|
+
* utils.overwriteChainableMethod(chai.Assertion.prototype, 'length',
|
|
4619
|
+
* function (_super) {
|
|
4620
|
+
* }
|
|
4621
|
+
* , function (_super) {
|
|
4622
|
+
* }
|
|
4623
|
+
* );
|
|
4624
|
+
*
|
|
4625
|
+
* Can also be accessed directly from `chai.Assertion`.
|
|
4626
|
+
*
|
|
4627
|
+
* chai.Assertion.overwriteChainableMethod('foo', fn, fn);
|
|
4628
|
+
*
|
|
4629
|
+
* Then can be used as any other assertion.
|
|
4630
|
+
*
|
|
4631
|
+
* expect(myFoo).to.have.length(3);
|
|
4632
|
+
* expect(myFoo).to.have.length.above(3);
|
|
4633
|
+
*
|
|
4634
|
+
* @param {Object} ctx object whose method / property is to be overwritten
|
|
4635
|
+
* @param {String} name of method / property to overwrite
|
|
4636
|
+
* @param {Function} method function that returns a function to be used for name
|
|
4637
|
+
* @param {Function} chainingBehavior function that returns a function to be used for property
|
|
4638
|
+
* @name overwriteChainableMethod
|
|
4639
|
+
* @api public
|
|
4640
|
+
*/
|
|
4641
|
+
|
|
4642
|
+
module.exports = function (ctx, name, method, chainingBehavior) {
|
|
4643
|
+
var chainableBehavior = ctx.__methods[name];
|
|
4644
|
+
|
|
4645
|
+
var _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
4646
|
+
chainableBehavior.chainingBehavior = function () {
|
|
4647
|
+
var result = chainingBehavior(_chainingBehavior).call(this);
|
|
4648
|
+
return result === undefined ? this : result;
|
|
4649
|
+
};
|
|
4650
|
+
|
|
4651
|
+
var _method = chainableBehavior.method;
|
|
4652
|
+
chainableBehavior.method = function () {
|
|
4653
|
+
var result = method(_method).apply(this, arguments);
|
|
4654
|
+
return result === undefined ? this : result;
|
|
4655
|
+
};
|
|
4656
|
+
};
|
|
4657
|
+
|
|
4469
4658
|
});
|
|
4470
4659
|
require.register("chai/lib/chai/utils/test.js", function(exports, require, module){
|
|
4471
4660
|
/*!
|
|
4472
4661
|
* Chai - test utility
|
|
4473
|
-
* Copyright(c) 2012-
|
|
4662
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4474
4663
|
* MIT Licensed
|
|
4475
4664
|
*/
|
|
4476
4665
|
|
|
@@ -4499,7 +4688,7 @@ module.exports = function (obj, args) {
|
|
|
4499
4688
|
require.register("chai/lib/chai/utils/transferFlags.js", function(exports, require, module){
|
|
4500
4689
|
/*!
|
|
4501
4690
|
* Chai - transferFlags utility
|
|
4502
|
-
* Copyright(c) 2012-
|
|
4691
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4503
4692
|
* MIT Licensed
|
|
4504
4693
|
*/
|
|
4505
4694
|
|
|
@@ -4546,7 +4735,7 @@ module.exports = function (assertion, object, includeAll) {
|
|
|
4546
4735
|
require.register("chai/lib/chai/utils/type.js", function(exports, require, module){
|
|
4547
4736
|
/*!
|
|
4548
4737
|
* Chai - type utility
|
|
4549
|
-
* Copyright(c) 2012-
|
|
4738
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4550
4739
|
* MIT Licensed
|
|
4551
4740
|
*/
|
|
4552
4741
|
|
|
@@ -4593,6 +4782,8 @@ module.exports = function (obj) {
|
|
|
4593
4782
|
});
|
|
4594
4783
|
|
|
4595
4784
|
|
|
4785
|
+
|
|
4786
|
+
|
|
4596
4787
|
require.alias("chaijs-assertion-error/index.js", "chai/deps/assertion-error/index.js");
|
|
4597
4788
|
require.alias("chaijs-assertion-error/index.js", "chai/deps/assertion-error/index.js");
|
|
4598
4789
|
require.alias("chaijs-assertion-error/index.js", "assertion-error/index.js");
|
|
@@ -4607,7 +4798,7 @@ require.alias("chaijs-deep-eql/lib/eql.js", "chaijs-deep-eql/index.js");
|
|
|
4607
4798
|
require.alias("chai/index.js", "chai/index.js");if (typeof exports == "object") {
|
|
4608
4799
|
module.exports = require("chai");
|
|
4609
4800
|
} else if (typeof define == "function" && define.amd) {
|
|
4610
|
-
define(function(){ return require("chai"); });
|
|
4801
|
+
define([], function(){ return require("chai"); });
|
|
4611
4802
|
} else {
|
|
4612
4803
|
this["chai"] = require("chai");
|
|
4613
4804
|
}})();
|