-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
MemberEquals assertion #148
Comments
+1, want want want. |
+1 How about this for language: // needle and haystack must have all of the same members
expect([ 1, 2, 3 ]).to.have.members([ 3, 2, 1 ]);
// needle can be subset of haystack
expect([ 1, 2, 3 ]).to.include.members([ 3, 1 ]); Thoughts? |
@logicalparadox seems like that would be subset, not set equality. |
@domenic The second example is subset, the first would behave the same as @NickHeiner's example. |
|
expect({ foo: 'bar', baz: 'zing' }).to.have.keys('foo', 'baz');
expect({ foo: 'bar', baz: 'zing' }).to.contain.key('foo'); Given this proposal is essentially the same thing but for arrays not objects it would be appropriate if the semantics matched... and this must be done without breaking Since these are all noops it is more of a matter of preference (and documentation) than anything else. Perhaps the best way to accomplish this is by adding another chainable that would allow you to be more expressive if you wish: expect([ 1, 2, 3 ]).to.have.exact.members(3, 2, 1); // or [ 3, 2, 1 ]
expect({ foo: 'bar', baz: 'zing' }).to.have.exact.keys('foo', 'baz'); // or [ 'foo', 'baz' ] |
…nd set equality. Implements chaijs#148.
…nd set equality. Implements chaijs#148.
…nd set equality. Implements chaijs#148.
* 'master' of github.com:chaijs/chai: giving members a no-flag assertion Code review comments - changing syntax Code review comments Adding members and memberEquals assertions for checking for subsets and set equality. Implements #148. Restore the `call` and `apply` methods of Function when adding a chainable method.
Merged into master... |
…nd set equality. Implements chaijs/chai#148.
It would be nice to assert that two arrays have the same members, regardless of order. (This would be used when we are treating arrays as sets, which aren't widely available in js yet.)
Can I submit a PR for this?
The text was updated successfully, but these errors were encountered: