-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
Fix bug when asserting some valid ES6 keys #676
Conversation
meeber
commented
Apr 9, 2016
- Resolution of assertKeys cannot handle some valid ES6 keys #674
- Add compareByInspect utility for use with assertKeys sorts
- Add getOwnEnumerableProperties utility
- Add getOwnEnumerablePropertySymbols utility
- Add Symbol support to the inspect utility
- Add tests to utilities, should, expect, and assert
@@ -1172,6 +1172,11 @@ module.exports = function (chai, _) { | |||
} else { | |||
actual = Object.keys(obj); | |||
|
|||
if (typeof Object.getOwnPropertySymbols === 'function') { | |||
// Object.keys excludes Symbols so we need this too | |||
actual = actual.concat(Object.getOwnPropertySymbols(obj)); |
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.
Slight concern with this - Object.getOwnPropertySymbols
returns enumerable and non-enumerable keys - somewhat changing the semantics of what this assertion already does. Should we filter out the non-enumerable keys? Something like:
actual = actual.concat(Object.getOwnPropertySymbols(obj).filter(function (symbol) {
return Object.getOwnPropertyDescriptor(obj, symbol).enumerable;
}));
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.
Whoops! Great catch. I'm on it :)
7b228ae
to
7a97a67
Compare
Fixed the issue with the non-enumerable symbols, and also modified a couple of the keys tests to validate that non-enumerable strings and symbols aren't included. |
I just went through it all and it LGTM! Note for later: We may need to solve merge conflicts on #668 |
Great, thank you! Just noticed a typo in the comments; gonna fix it real quick. Edit: fixed |
- Resolution of chaijs#674 - Add compareByInspect utility for use with assertKeys sorts - Add getOwnEnumerableProperties utility - Add getOwnEnumerablePropertySymbols utility - Add Symbol support to the inspect utility - Add tests to utilities, should, expect, and assert
7a97a67
to
e228351
Compare
LGTM 👍 |