Add stringifyQuery unit test#76
Conversation
| it.each( [ | ||
| [ 'lorem', '0=l&0=o&0=r&0=e&0=m' ], | ||
| [ { product: '1885' }, '0,1,2,3=1,8,8,5' ], | ||
| [ [ { product: '1885', action: 'hook_name' } ], 'product,action=1885,hook_name' ], |
There was a problem hiding this comment.
@AdrianFiroiu I think it’s a valid example, and you can remove it. What is your opinion on it?
There was a problem hiding this comment.
Well my initial thought behind this case starts from the fact that this utility expects the input to be an array of single key/value pair objects but if the object we supply has multiple key/value pairs, then the output is IMO invalid.
At least to me, the output 'product,action=1885,hook_name' does not represent a valid query string and I can't really see a use case for it. Please let me know if I could be wrong.
This could also be classified as a bug and we should actually support multiple key/value pairs in a single object?
There was a problem hiding this comment.
Yes @AdrianFiroiu , I agree, it should support multiple values and keys. @kuserich @mahdiyazdani What do you think?
There was a problem hiding this comment.
Thank you @kuserich. So, @AdrianFiroiu would you please move this to the Valid arrays and replace the equal value with a value that we expected to have?
There was a problem hiding this comment.
Thank you @kuserich. So, @AdrianFiroiu would you please move this to the Valid arrays and replace the equal value with a value that we expected to have?
I would be in favour of leaving it as is and moving / replacing it when we fix the issue.
kuserich
left a comment
There was a problem hiding this comment.
Thank you, @AdrianFiroiu . I have removed the test cases that do not provide an Array input as they are invalid by definition (function expects arrays).
I'm in favour of keeping the test case with multiple fields and update the test case in the same PR that updates the function.
| it.each( [ | ||
| [ 'lorem', '0=l&0=o&0=r&0=e&0=m' ], | ||
| [ { product: '1885' }, '0,1,2,3=1,8,8,5' ], | ||
| [ [ { product: '1885', action: 'hook_name' } ], 'product,action=1885,hook_name' ], |
There was a problem hiding this comment.
Thank you @kuserich. So, @AdrianFiroiu would you please move this to the Valid arrays and replace the equal value with a value that we expected to have?
This PR proposes a test suite for the
stringifyQueryutility. Please let me know if I should extend it with any further test cases.