diff --git a/changes/ana_add-choosefilter-for-pagevalidator b/changes/ana_add-choosefilter-for-pagevalidator new file mode 100644 index 0000000000..a5b4883c2b --- /dev/null +++ b/changes/ana_add-choosefilter-for-pagevalidator @@ -0,0 +1 @@ +[Changed] [#3289](https://github.com/cosmos/lunie/pull/3289) Now PageValidator handles empty fields more uniformly, always displaying `--` @Bitcoinera \ No newline at end of file diff --git a/src/components/staking/PageValidator.vue b/src/components/staking/PageValidator.vue index d2704989c6..8f5274e93e 100644 --- a/src/components/staking/PageValidator.vue +++ b/src/components/staking/PageValidator.vue @@ -66,7 +66,7 @@
  • Website

    - +
  • Uptime

    - - {{ validator.uptimePercentage | percent }} - + {{ + isBlankField(validator.uptimePercentage, percent) + }}
  • Current Commission Rate

    - {{ validator.commission | percent }} + {{ isBlankField(validator.commission, percent) }}
  • Max Commission Rate

    - {{ validator.maxCommission | percent }} + {{ isBlankField(validator.maxCommission, percent) }}
  • Max Daily Commission Change

    - {{ validator.maxChangeCommission | percent }} + {{ + isBlankField(validator.maxChangeCommission, percent) + }}
  • Last Commission Change

    - {{ validator.commissionUpdateTime | fromNow }} + {{ + isBlankField(validator.commissionUpdateTime, fromNow) + }}
  • @@ -230,6 +234,8 @@ export default { shortDecimals, atoms, percent, + fromNow, + noBlanks, moment, onDelegation(options) { this.$refs.delegationModal.open(options) @@ -251,6 +257,9 @@ export default { `undelegations`, `transactions` ]) // TODO use more finegrained query string (network and address) + }, + isBlankField(field, alternateFilter) { + return field ? alternateFilter(field) : noBlanks(field) } }, apollo: { diff --git a/tests/unit/specs/components/common/TmSessionHardware.spec.js b/tests/unit/specs/components/common/TmSessionHardware.spec.js index 5072fc3360..766a7c483d 100644 --- a/tests/unit/specs/components/common/TmSessionHardware.spec.js +++ b/tests/unit/specs/components/common/TmSessionHardware.spec.js @@ -6,8 +6,8 @@ import TmSessionHardware from "common/TmSessionHardware" const localVue = createLocalVue() localVue.use(Vuex) localVue.use(Vuelidate) -localVue.directive(`tooltip`, () => { }) -localVue.directive(`focus`, () => { }) +localVue.directive(`tooltip`, () => {}) +localVue.directive(`focus`, () => {}) describe(`TmSessionHardware`, () => { let wrapper, store diff --git a/tests/unit/specs/components/staking/PageValidator.spec.js b/tests/unit/specs/components/staking/PageValidator.spec.js index 3ced5ce70e..f61886bd94 100644 --- a/tests/unit/specs/components/staking/PageValidator.spec.js +++ b/tests/unit/specs/components/staking/PageValidator.spec.js @@ -97,4 +97,21 @@ describe(`PageValidator`, () => { $store.state.session.signedIn = false expect(wrapper.element).toMatchSnapshot() }) + it(`if uptimePercentage is blank`, () => { + wrapper.setProps({ validator: { uptimePercentage: `` } }) + expect(wrapper.element).toMatchSnapshot() + }) +}) + +describe(`isBlankField method`, () => { + it(`returns "--"`, async () => { + validator.maxCommission = null + const percent = jest.fn() + const afterFilter = PageValidator.methods.isBlankField( + validator.maxCommission, + percent + ) + + expect(afterFilter).toBe(`--`) + }) }) diff --git a/tests/unit/specs/components/staking/__snapshots__/PageValidator.spec.js.snap b/tests/unit/specs/components/staking/__snapshots__/PageValidator.spec.js.snap index cfcf614b15..1783fc195e 100644 --- a/tests/unit/specs/components/staking/__snapshots__/PageValidator.spec.js.snap +++ b/tests/unit/specs/components/staking/__snapshots__/PageValidator.spec.js.snap @@ -1,5 +1,35 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`PageValidator if uptimePercentage is blank 1`] = ` + +
    + Validator Not Found +
    + +
    + + Please visit the + + + Validators + + page to view + all validators + +
    +
    +`; + exports[`PageValidator if user has signed in - status text banned 1`] = ` { }) it(`should return an abbreviated version of an Ethereum address, with "0x" and then the first four characters, followed by "..." and finally the last four characters`, () => { - expect(formatBech32(`0x00b1606fc5b771f3079b4fd3ea49e66a2d5fd665`)).toBe(`0x00b1…d665`) + expect(formatBech32(`0x00b1606fc5b771f3079b4fd3ea49e66a2d5fd665`)).toBe( + `0x00b1…d665` + ) }) it(`should return 'Not A Valid Bech32 Address' when no 1 is present`, () => {