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

Validate expression values for enum-typed properties #5589

Merged
merged 1 commit into from
Nov 3, 2017

Conversation

anandthakker
Copy link
Contributor

@@ -148,6 +153,9 @@ function createExpression(expression: mixed,
if (val === null || val === undefined) {
return defaultValue;
}
if (enumValues && enumValues.indexOf(val) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason to use indexOf here rather than val in values?

@@ -19,3 +19,26 @@ test('createExpression', (t) => {

t.end();
});

test('evaluate expression', (t) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be an integration test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It started out that way, but the expression tests use the non-error-checking createExpression() so they can check error messages. Since this is a post-evaluation check specific to the error-checking path, it's not a great fit for those tests.

🤔 We could add a render test, though.

@anandthakker
Copy link
Contributor Author

@jfirebaugh added a render test and switched to val in enumValues

@anandthakker anandthakker merged commit de53c56 into master Nov 3, 2017
@anandthakker anandthakker deleted the expression-enums branch November 3, 2017 19:22
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.

2 participants