mirror of
https://github.com/chaijs/chai
synced 2024-11-15 00:07:11 +00:00
assert: [(not)include] throw on incompatible haystack. Closes #142
This commit is contained in:
parent
8f8d7425a5
commit
019bb07637
2 changed files with 18 additions and 0 deletions
|
@ -645,6 +645,11 @@ module.exports = function (chai, util) {
|
|||
obj.to.include(inc);
|
||||
} else if ('string' === typeof exp) {
|
||||
obj.to.contain.string(inc);
|
||||
} else {
|
||||
throw new chai.AssertionError({
|
||||
message: 'expected an array or string'
|
||||
, stackStartFunction: assert.include
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -671,6 +676,11 @@ module.exports = function (chai, util) {
|
|||
obj.to.not.include(inc);
|
||||
} else if ('string' === typeof exp) {
|
||||
obj.to.not.contain.string(inc);
|
||||
} else {
|
||||
throw new chai.AssertionError({
|
||||
message: 'expected an array or string'
|
||||
, stackStartFunction: assert.include
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -357,6 +357,10 @@ suite('assert', function () {
|
|||
err(function () {
|
||||
assert.include('foobar', 'baz');
|
||||
}, "expected \'foobar\' to contain \'baz\'");
|
||||
|
||||
err(function () {
|
||||
assert.include(undefined, 'bar');
|
||||
}, "expected an array or string");
|
||||
});
|
||||
|
||||
test('notInclude', function () {
|
||||
|
@ -366,6 +370,10 @@ suite('assert', function () {
|
|||
err(function () {
|
||||
assert.notInclude('foobar', 'bar');
|
||||
}, "expected \'foobar\' to not contain \'bar\'");
|
||||
|
||||
err(function () {
|
||||
assert.notInclude(undefined, 'bar');
|
||||
}, "expected an array or string");
|
||||
});
|
||||
|
||||
test('lengthOf', function() {
|
||||
|
|
Loading…
Reference in a new issue