Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,10 @@
undefined,
ssfi
);
case 'function': {
case 'function':
case 'asyncfunction':
case 'generatorfunction':
case 'asyncgeneratorfunction': {
const msg = flagMsg + '.empty was passed a function ' + _.getName(val);
throw new AssertionError(msg.trim(), undefined, ssfi);
}
Expand Down Expand Up @@ -3065,7 +3068,7 @@
*
* @name satisfy
* @alias satisfies
* @param {Function} matcher

Check warning on line 3071 in lib/chai/core/assertions.js

View workflow job for this annotation

GitHub Actions / lint

Prefer a more specific type to `Function`
* @param {string} msg _optional_
* @namespace BDD
* @public
Expand Down Expand Up @@ -3373,7 +3376,7 @@
* expect(1, 'nooo why fail??').to.be.oneOf([2, 3, 4]);
*
* @name oneOf
* @param {Array<*>} list

Check warning on line 3379 in lib/chai/core/assertions.js

View workflow job for this annotation

GitHub Actions / lint

Prefer a more specific type to `*`
* @param {string} msg _optional_
* @namespace BDD
* @public
Expand Down
8 changes: 8 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2941,6 +2941,10 @@ describe('assert', function () {
assert[isEmpty](function() {}, 'blah');
}, "blah: .empty was passed a function");

err(function(){
assert[isEmpty](async function() {}, 'blah');
}, "blah: .empty was passed a function");

if (FakeArgs.name === 'FakeArgs') {
err(function(){
assert[isEmpty](FakeArgs);
Expand Down Expand Up @@ -3039,6 +3043,10 @@ describe('assert', function () {
assert[isNotEmpty](function() {}, 'blah');
}, "blah: .empty was passed a function");

err(function(){
assert[isNotEmpty](function*() {}, 'blah');
}, "blah: .empty was passed a function");

if (FakeArgs.name === 'FakeArgs') {
err(function(){
assert[isNotEmpty](FakeArgs);
Expand Down
12 changes: 12 additions & 0 deletions test/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,18 @@ describe('expect', function () {
expect(function() {}, 'blah').to.be.empty;
}, "blah: .empty was passed a function");

err(function(){
expect(async function() {}, 'blah').to.be.empty;
}, "blah: .empty was passed a function");

err(function(){
expect(function*() {}, 'blah').to.be.empty;
}, "blah: .empty was passed a function");

err(function(){
expect(async function*() {}, 'blah').to.not.be.empty;
}, "blah: .empty was passed a function");

if (FakeArgs.name === 'FakeArgs') {
err(function(){
expect(FakeArgs).to.be.empty;
Expand Down
Loading