-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
03ac0e3
to
02fd677
Compare
@@ -75,6 +76,8 @@ const PurseAmountInput = ({ | |||
decimalPlaces={decimalPlaces} | |||
placesToShow={placesToShow} | |||
disabled={amountInputDisabled} | |||
error={error !== null} | |||
helperText={error ?? ' '} |
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.
There may be a need for non-error helper text for a different feature, but that can be handled separately when needed.
The ' ' is a hack to prevent the height of the input from changing (and moving around the UI) when the helperText appears and disappears.
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.
Is ??
in standard JS yet? Or is that transformed by our bundler? Just curious, I suppose.
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 debtInput = component.find(NatPurseAmountInput).at(1); | ||
expect(debtInput.props().error).toEqual(null); | ||
|
||
act(() => debtInput.props().onAmountChange(0n)); |
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.
Technically this is only testing that it shows an error when AmountMath.subtract throws (it's mocked above), not anything to do with the actual amount values used, but we need to mock AmountMath since it requires ses which is incompatible with jest jestjs/jest#11952
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.
testing looks good.
let newAmount; | ||
try { | ||
newAmount = AmountMath.subtract(locked, collDelta); |
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.
Changing const newAmount
to let newAmount
just because JS doesn't have try
expressions but only statements always bugs me. But oh well.
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.
Yea, I could avoid it by stuffing more into the try-block, but I think it's better to isolate the error as specifically as possible
@@ -75,6 +76,8 @@ const PurseAmountInput = ({ | |||
decimalPlaces={decimalPlaces} | |||
placesToShow={placesToShow} | |||
disabled={amountInputDisabled} | |||
error={error !== null} | |||
helperText={error ?? ' '} |
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.
Is ??
in standard JS yet? Or is that transformed by our bundler? Just curious, I suppose.
fixes: #248
Instead of crashing/throwing an app-level error, show an invalid input with a message indicating the locked/debt amount to subtract exceeds the current locked/debt amount
Also tweaked the cancel button so that it didn't look like a primary action
Screenshot:
