Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set support in same members #1583

Merged
merged 9 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make changes after merging
  • Loading branch information
koddsson committed Feb 11, 2024
commit d3a37bf33522d11aa134af2a39f881e386d0fff3
26 changes: 10 additions & 16 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ function an (type, msg) {
, 'expected #{this} to be ' + article + type
, 'expected #{this} not to be ' + article + type
);
} else if (type === 'iterable') {
this.assert(
typeof obj !== 'string' && obj != undefined && obj[Symbol.iterator]
, 'expected #{this} to be ' + article + type
, 'expected #{this} not to be ' + article + type
);
} else {
this.assert(
type === detectedType
Expand All @@ -337,14 +331,6 @@ function an (type, msg) {
Assertion.addChainableMethod('an', an);
Assertion.addChainableMethod('a', an);

function SameValueZero(a, b) {
return (_.isNaN(a) && _.isNaN(b)) || a === b;
}

function includeChainingBehavior () {
flag(this, 'contains', true);
}

/**
* ### .include(val[, msg])
*
Expand Down Expand Up @@ -492,6 +478,14 @@ function includeChainingBehavior () {
* @api public
*/

function SameValueZero(a, b) {
return (_.isNaN(a) && _.isNaN(b)) || a === b;
}

function includeChainingBehavior () {
flag(this, 'contains', true);
}

function include (val, msg) {
if (msg) flag(this, 'message', msg);

Expand Down Expand Up @@ -3147,8 +3141,8 @@ Assertion.addMethod('members', function (subset, msg) {
, flagMsg = flag(this, 'message')
, ssfi = flag(this, 'ssfi');

new Assertion(obj, flagMsg, ssfi, true).to.be.an('iterable');
new Assertion(subset, flagMsg, ssfi, true).to.be.an('iterable');
new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;

var contains = flag(this, 'contains');
var ordered = flag(this, 'ordered');
Expand Down
4 changes: 2 additions & 2 deletions test/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -2815,11 +2815,11 @@ describe('should', function() {

err(function() {
'foo'.should.include.members([12], 'blah');
}, "blah: expected 'foo' to be an iterable");
}, "blah: expected 'foo' to be a superset of [ 12 ]");

err(function() {
[1, 2, 3].should.include.members('o', 'blah');
}, "blah: expected 'o' to be an iterable");
}, "blah: expected [ 1, 2, 3 ] to be a superset of 'o'");
});

it('memberEquals', function() {
Expand Down