refactor: update user-query functions to use new inquirer#760
refactor: update user-query functions to use new inquirer#760rossiam merged 1 commit intoSmartThingsCommunity:yargsfrom
Conversation
|
ec5fc1b to
8fb6b29
Compare
| }) | ||
|
|
||
| it.each([5, 10, -5, 3.141592653])('rejects %s', input => { | ||
| expect(numberValidateFn()(input)).toBe(true) |
There was a problem hiding this comment.
This test could use another look--seems like it was meant to be an update of the previous test but didn't quite get finished.
There was a problem hiding this comment.
Oops, both of these tests were from when this function validated strings rather than numbers. I've removed them.
| const minLength = await optionalIntegerInput('Optional minimum length.', { validate: numberValidateFn({ min: 0 }) }) | ||
| const maxLength = await optionalIntegerInput( | ||
| 'Optional maximum length.', | ||
| { validate: numberValidateFn({ min: minLength || 1 }) }, |
There was a problem hiding this comment.
Since this is an optional integer, should the alternate minLength be 0 rather than 1?
There was a problem hiding this comment.
This is a bit complicated but I did deliberately use 1. It seems sensible to me that a user might want a string attribute that has a fixed length (minLength and maxLength are the same value) if it's 1 or more which is why we use minLength if one is set but having a string with a min and max length both set to zero seems wrong.
|
|
||
| it.each(['input value', '7'])('returns input value unchanged when not empty', value => { | ||
| expect(numberTransformer(value, { value }, { isFinal: true })).toBe(value) | ||
| it.each(['input value', '7'])('returns input value %s unchanged when', value => { |
There was a problem hiding this comment.
"unchanged when"....? 'not empty' was removed here, perhaps by mistake?
There was a problem hiding this comment.
Oops, fixed. It was correct to remove not empty but it was not correct to include final instead. 😄 My excuse is that I must have been interrupted.
8fb6b29 to
eb82ffd
Compare
user-querymodulenumber | undefinedinstead ofstringand the query function does the number validation before passing the input on to custom validator as a numberurlValidateFnwas allowing URLs missing a/likehttps:/invalid-url.comThe old inquirer is still included. A second PR will update the rest of the code and remove it entirely.