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

Fix bug when asserting some valid ES6 keys #676

Merged
merged 1 commit into from
Apr 12, 2016

Conversation

meeber
Copy link
Contributor

@meeber 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));
Copy link
Member

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;
}));

Copy link
Contributor Author

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 :)

@meeber
Copy link
Contributor Author

meeber commented Apr 10, 2016

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.

@lucasfcosta
Copy link
Member

I just went through it all and it LGTM!
Awesome work, thanks for including complete tests for the features you've just implemented.
I really, really liked it.


Note for later: We may need to solve merge conflicts on #668

@meeber
Copy link
Contributor Author

meeber commented Apr 11, 2016

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
@keithamus
Copy link
Member

LGTM 👍

@keithamus keithamus merged commit 9c89bf0 into chaijs:master Apr 12, 2016
@meeber meeber deleted the es6-keys-asserts branch August 6, 2017 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants