Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test($parse): add tests for watching one-time array/object literals #16477

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

jbedard
Copy link
Collaborator

@jbedard jbedard commented Mar 6, 2018

These are some examples of cases which 189461f enabled. All the one-time tests failed before that commit.

It's possible that these overlap with these tests a bit (the non-deep ones), but I think at least the should ignore changes within nested objects tests are a good addition.

return input;
}));

scope.$watch('[(a | foo:b:1), undefined]');
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of including the params b and 1 here?
Should you not also be checking what happens if b change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question... I have no idea why I added those. I guess I'll just delete them, or if I think of a reason maybe they deserve a separate test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm... I guess I added it because the tests above and below the new tests have it as well (which I wrote some time ago)!

I think the original reason was to ensure that constant/variables as filter arguments do not effect what is being tested. While it doesn't truely test that because it never assigns a value to the b variable, I think I'd vote to leave it anyway, partially just to be consistent with the other tests around it... WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am indifferent, it just stood out to me as something unexplained.


scope.a++;
scope.$digest();
expect(filterCalls).toEqual([0, 1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unexpected. If this is a one-time binding, shouldn't we be ignoring the filter once the binding has a value?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or does the undefined in the second element of the array prevent the one time binding from stabilizing?

Copy link
Member

Choose a reason for hiding this comment

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

Exactly! For ::[ ] and ::{ }, all values must be defined before unwatching the whole expression.

@jbedard jbedard force-pushed the parse-onetime-literal-tests branch from 14903cf to aca25d3 Compare March 14, 2018 06:16
@jbedard
Copy link
Collaborator Author

jbedard commented Mar 18, 2018

I think all the tests passed despite the failed build...?

@jbedard jbedard force-pushed the parse-onetime-literal-tests branch from aca25d3 to 30c836e Compare March 31, 2018 22:43
@Narretz Narretz merged commit 71d2c14 into angular:master Apr 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants