-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
Integrated chai-subset
and added assert-based negation to containSubset
#1664
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,206 @@ | |||
import {assert, expect} from '../index.js'; | |||
|
|||
describe('plain object', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file should have a root describe('containsSubset', ...)
block which these all live below
if (typeof expected !== 'object' || expected === null) { | ||
return expected === actual; | ||
} | ||
if (!!expected && !actual) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point, we already know expected
is an NonNull<object>
and actual
is object
, so you can avoid the !!
if (!!expected && !actual) { | |
if(!actual) { | |
return false; | |
} |
if (typeof actual.length !== 'number') { | ||
return false; | ||
} | ||
var aa = Array.prototype.slice.call(actual); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we clone the array? and why we don't use Array.isArray(actual)
above?
we should also add tests for using this with should and assert style assertions otherwise looks good so far though 👍 |
A revival of @koddsson 's previous attempt at merging the abandoned
chai-subset
functionality, with some added comments and an assert-style negation of containSubset which was not present in the original package. I know there was some concern about code duplication in the original PR, so I'm happy to respond to feedback! Thanks all.Fixes #1616