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

fedekunze/1409 fix bond amount #1498

Merged
merged 12 commits into from
Nov 3, 2018
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1480](https://github.com/cosmos/voyager/issues/1480) Fixed "duplicate CONN" errors in E2E tests. @NodeGuy
* [\#1480](https://github.com/cosmos/voyager/issues/1480) Fixed false detection of node crash in e2e test start. @faboweb
* [\#1451](https://github.com/cosmos/voyager/issues/1451) Provide better sourcemaps to make debugging easier. @faboweb
* [\#1409](https://github.com/cosmos/voyager/issues/1409) Fixed disabled unbond and redelegation button when delegation amount was less than 1 @fedekunze

## [0.10.7] - 2018-10-10

Expand Down
10 changes: 6 additions & 4 deletions app/src/renderer/components/staking/DelegationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
field-label='Amount'
)
tm-field#denom(
type="number"
type="text"
:placeholder="bondingDenom"
readonly)

tm-field#amount(
type="number"
:max="fromOptions[selectedIndex].maximum"
:min="0"
step="1"
step="any"
v-model="amount"
v-focus)

Expand Down Expand Up @@ -73,8 +73,10 @@ export default {
return {
amount: {
required,
integer: value => Number.isInteger(value),
between: between(1, this.fromOptions[this.selectedIndex].maximum)
between: between(
0.0000000001,
this.fromOptions[this.selectedIndex].maximum
)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
tm-field#amount(
:max="maximum"
:min="0"
step="any"
type="number"
v-model="amount"
v-focus)
Expand Down
27 changes: 27 additions & 0 deletions test/unit/specs/components/staking/DelegationModal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ test(`Delegation button submits delegation and closes modal`, () => {
])
})

test(`only allow maximum owned atoms`, () => {
const wrapper = Wrapper()

wrapper.find(`#amount`).element.value = 142
wrapper.find(`#amount`).trigger(`input`)
wrapper.update()
expect(wrapper.find(`#amount`).element.value).toBe(`100`)

wrapper.vm.onDelegation()

expect(wrapper.emittedByOrder()).toEqual([
{
name: `submitDelegation`,
args: [
{
amount: 100,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
}
]
},
{
name: `update:showDelegationModal`,
args: [false]
}
])
})

test(`X button emits close signal`, () => {
const wrapper = Wrapper()
wrapper.vm.close()
Expand Down
27 changes: 27 additions & 0 deletions test/unit/specs/components/staking/UndelegationModal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ test(`unstake button emits the unstake signal`, () => {
])
})

test(`only allow maximum owned atoms`, () => {
const wrapper = Wrapper()
wrapper.setProps({ maximum: 4.2 })

wrapper.find(`#amount`).element.value = 50
wrapper.find(`#amount`).trigger(`input`)
wrapper.update()
expect(wrapper.find(`#amount`).element.value).toBe(`4.2`)

wrapper.vm.onUndelegate()

expect(wrapper.emittedByOrder()).toEqual([
{
name: `submitUndelegation`,
args: [
{
amount: 4.2
}
]
},
{
name: `update:showUndelegationModal`,
args: [false]
}
])
})

test(`X button emits close signal`, () => {
const wrapper = Wrapper()
wrapper.vm.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`renders correctly 1`] = `
<!---->
<label for=\\"amount\\" class=\\"tm-form-group__label\\">Amount</label>
<div class=\\"tm-form-group__field\\">
<input type=\\"number\\" placeholder=\\"atom\\" class=\\"tm-field\\" id=\\"denom\\" readonly=\\"readonly\\"><input type=\\"number\\" max=\\"100\\" min=\\"0\\" class=\\"tm-field\\" id=\\"amount\\" step=\\"1\\">
<input type=\\"text\\" placeholder=\\"atom\\" class=\\"tm-field\\" id=\\"denom\\" readonly=\\"readonly\\"><input type=\\"number\\" max=\\"100\\" min=\\"0\\" class=\\"tm-field\\" id=\\"amount\\" step=\\"any\\">
</div>
</div>
<div class=\\"delegation-modal-form-group tm-form-group\\">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`renders correctly 1`] = `
<!---->
<!---->
<div class=\\"tm-form-group__field\\">
<input type=\\"text\\" placeholder=\\"atom\\" class=\\"tm-field\\" id=\\"denom\\" readonly=\\"readonly\\"><input type=\\"number\\" max=\\"100\\" min=\\"0\\" class=\\"tm-field\\" id=\\"amount\\">
<input type=\\"text\\" placeholder=\\"atom\\" class=\\"tm-field\\" id=\\"denom\\" readonly=\\"readonly\\"><input type=\\"number\\" max=\\"100\\" min=\\"0\\" class=\\"tm-field\\" id=\\"amount\\" step=\\"any\\">
</div>
</div>
<div class=\\"undelegation-modal-form-group tm-form-group\\">
Expand Down