Skip to content

Commit

Permalink
use mapactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Voyager Bot committed Nov 6, 2018
1 parent 971ad74 commit f47d038
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
15 changes: 8 additions & 7 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ tm-page(data-title="Validator")

delegation-modal(
v-if="showDelegationModal"
v-on:submitDelegation="submitDelegation"
v-on:submitDelegation="onSubmitDelegation"
:showDelegationModal.sync="showDelegationModal"
:fromOptions="delegationTargetOptions()"
:to="validator.operator_address"
)

undelegation-modal(
v-if="showUndelegationModal"
v-on:submitUndelegation="submitUndelegation"
v-on:onSubmitUndelegation="onSubmitUndelegation"
:showUndelegationModal.sync="showUndelegationModal"
:maximum="myBond"
:to="this.wallet.address"
Expand All @@ -115,7 +115,7 @@ tm-page(data-title="Validator")
<script>
import moment from "moment"
import { calculateTokens } from "scripts/common"
import { mapGetters } from "vuex"
import { mapGetters, mapActions } from "vuex"
import num from "scripts/num"
import { TmBtn, TmListItem, TmPage, TmPart, TmToolBar } from "@tendermint/ui"
import TmModal from "common/TmModal"
Expand Down Expand Up @@ -227,6 +227,7 @@ export default {
}
},
methods: {
...mapActions([`submitDelegation`]),
closeCannotModal() {
this.showCannotModal = false
},
Expand All @@ -246,7 +247,7 @@ export default {
this.showCannotModal = true
}
},
async submitDelegation({ amount, from }) {
async onSubmitDelegation({ amount, from }) {
const delegatorAddr = this.wallet.address
let stakingTransactions = {}
let txTitle,
Expand Down Expand Up @@ -283,7 +284,7 @@ export default {
}
try {
await this.$store.dispatch(`submitDelegation`, {
await this.submitDelegation({
stakingTransactions
})
Expand All @@ -310,9 +311,9 @@ export default {
}
}
},
async submitUndelegation({ amount }) {
async onSubmitUndelegation({ amount }) {
try {
await this.$store.dispatch(`submitDelegation`, {
await this.submitDelegation({
stakingTransactions: {
unbondings: [
{
Expand Down
50 changes: 25 additions & 25 deletions test/unit/specs/components/staking/PageValidator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -472,7 +472,7 @@ describe(`onDelegation`, () => {

$store.dispatch.mockClear()

await submitDelegation({
await onSubmitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
})
Expand Down Expand Up @@ -502,7 +502,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -525,7 +525,7 @@ describe(`onDelegation`, () => {
throw new Error(`message`)
})

await submitDelegation({
await onSubmitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
})
Expand Down Expand Up @@ -553,7 +553,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -576,7 +576,7 @@ describe(`onDelegation`, () => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
})

await submitDelegation({
await onSubmitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
})
Expand Down Expand Up @@ -619,7 +619,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: { params: { validator: lcdClientMock.validators[0] } },
Expand All @@ -629,7 +629,7 @@ describe(`onDelegation`, () => {

$store.dispatch.mockClear()

await submitDelegation({
await onSubmitDelegation({
amount: 10,
from: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`
})
Expand Down Expand Up @@ -720,7 +720,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -740,7 +740,7 @@ describe(`onDelegation`, () => {

$store.dispatch.mockClear()

await submitDelegation({
await onSubmitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
})
Expand Down Expand Up @@ -770,7 +770,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -793,7 +793,7 @@ describe(`onDelegation`, () => {
throw new Error(`message`)
})

await submitDelegation({
await onSubmitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
})
Expand Down Expand Up @@ -821,7 +821,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -844,7 +844,7 @@ describe(`onDelegation`, () => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix\nseven`)
})

await submitDelegation({
await onSubmitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
})
Expand Down Expand Up @@ -887,7 +887,7 @@ describe(`onDelegation`, () => {
}

const {
vm: { submitDelegation }
vm: { onSubmitDelegation }
} = mount(PageValidator, {
mocks: {
$route: {
Expand All @@ -901,7 +901,7 @@ describe(`onDelegation`, () => {

$store.dispatch.mockClear()

await submitDelegation({
await onSubmitDelegation({
amount: 5,
from: lcdClientMock.validators[0]
})
Expand Down Expand Up @@ -1014,7 +1014,7 @@ describe(`onUnstake`, () => {
})
})

describe(`submitUndelegation`, () => {
describe(`onSubmitUndelegation`, () => {
describe(`unit`, () => {
it(`success`, async () => {
const $store = {
Expand All @@ -1024,7 +1024,7 @@ describe(`onUnstake`, () => {
}

const {
vm: { submitUndelegation }
vm: { onSubmitUndelegation }
} = mount(PageValidator, {
mocks: {
$route: { params: { validator: lcdClientMock.validators[0] } },
Expand All @@ -1034,7 +1034,7 @@ describe(`onUnstake`, () => {

$store.dispatch.mockClear()

await submitUndelegation({ amount: 10 })
await onSubmitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
[
Expand Down Expand Up @@ -1062,7 +1062,7 @@ describe(`onUnstake`, () => {
}

const {
vm: { submitUndelegation }
vm: { onSubmitUndelegation }
} = mount(PageValidator, {
mocks: {
$route: { params: { validator: lcdClientMock.validators[0] } },
Expand All @@ -1075,7 +1075,7 @@ describe(`onUnstake`, () => {
throw new Error(`message`)
})

await submitUndelegation({ amount: 10 })
await onSubmitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
[
Expand Down Expand Up @@ -1103,7 +1103,7 @@ describe(`onUnstake`, () => {
}

const {
vm: { submitUndelegation }
vm: { onSubmitUndelegation }
} = mount(PageValidator, {
mocks: {
$route: { params: { validator: lcdClientMock.validators[0] } },
Expand All @@ -1116,7 +1116,7 @@ describe(`onUnstake`, () => {
throw new Error(`one\ntwo\nthree\nfour\nfive\nsix"seven`)
})

await submitUndelegation({ amount: 10 })
await onSubmitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
[
Expand Down Expand Up @@ -1161,7 +1161,7 @@ describe(`onUnstake`, () => {
}

const {
vm: { submitUndelegation }
vm: { onSubmitUndelegation }
} = mount(PageValidator, {
mocks: {
$route: { params: { validator: lcdClientMock.validators[0] } },
Expand All @@ -1171,7 +1171,7 @@ describe(`onUnstake`, () => {

$store.dispatch.mockClear()

await submitUndelegation({ amount: 10 })
await onSubmitUndelegation({ amount: 10 })

expect($store.dispatch.mock.calls).toEqual([
[
Expand Down

0 comments on commit f47d038

Please sign in to comment.