-
Notifications
You must be signed in to change notification settings - Fork 72
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
add newSelectorLogic method #501
Conversation
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.
Hey @cescoferraro I left some comments and concerns. Let me know what you think
@@ -0,0 +1,20 @@ | |||
import {IItemSelector} from '../../types/Assertion.types'; | |||
|
|||
export function newSelectorLogic(selectorList: IItemSelector[]): string { |
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.
Let's move this to the Assertion service
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.
I think we can change this to be more verbose by doing something like:
const getFilters = (selectorList) => {
return selectorList.map(({propertyName, operator, value, valueType}) => `${propertyName} ${operator || '='} ${getValue(value, valueType)}`);
}
const result `span[${getFilters(selectorList).join(' ')}]`;
result += selector.propertyName; | ||
result += selector.operator ? ` ${selector.operator.toLowerCase()} ` : '='; | ||
// add quotes if value is a string | ||
if (selector.valueType === 'stringValue') result += `'`; |
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.
I think we should have a more complex way of creating this chunk to support the other value types.
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.
Something like getValueString(value, valueType)
;
Then we can decide how to create each of them
This PR create a method to transform
selectorList: IItemSelector[]
to a selector string described hereChanges
Checklist