Skip to content

Fix expect(new Array(1)).toEqual([undefined]) failures on *some* platforms #1048

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

Merged
merged 4 commits into from
Oct 17, 2016

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Oct 17, 2016

This test adds a helper function to the lib test in order to loosen the comparison to what we actually care about, which is array access, not array content.

Gross.

@rreusser rreusser added bug something broken status: reviewable labels Oct 17, 2016
var i;
if(Array.isArray(x)) {
for(i = 0; i < x.length; i++) {
x[i] = x[i];
Copy link
Contributor Author

@rreusser rreusser Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😐

});

it('expands bracketed array notation with further nesting', function() {
var input = {'marker[1].size.magnitude': 8};
var expected = {marker: [undefined, {size: {magnitude: 8}}]};
var computed = Lib.expandObjectPaths(input);
expect(computed).toEqual(expected);
expectLooseDeepEqual(computed, expected);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of that custom assert routine, why not just have to expect statements:

expect(computed.marker[0]).toBeUndefined();
expect(computed.marker[1]).toEqual({ size: { magnitude: 8 } });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move the function inside this block, but ideally wanted to avoid manually digging through the objects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that make sense.

What about moving your new expectLooseDeepEqual to assets/custom_matchers.js ?

@rreusser
Copy link
Contributor Author

rreusser commented Oct 17, 2016

@etpinard added expect(...).toLooseDeepEqual(...). It wasn't straightforward to try to hook into jasmine's internals, so I just did the check via the deep-equal module. If it passes, that should get it.

@etpinard
Copy link
Contributor

💃 once test pass! Thanks!

@rreusser rreusser merged commit 17102d8 into master Oct 17, 2016
@rreusser rreusser deleted the fix-deep-equal-sloppiness branch October 17, 2016 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants