Skip to content
Permalink
Browse files

chore: release 2.2.1 (ArkEcosystem#1041)

* improvement: make wallet heading name more visible in dark mode (ArkEcosystem#996)

* fix: correctly handle zero balance on wallet heading info (ArkEcosystem#1000)

* fix: conditional alignment of items (ArkEcosystem#1005)

* improvement: adjust announcement section to fit new design (ArkEcosystem#982)

* improvement: new instructions section for wallet import/new and network overview page (ArkEcosystem#1003)

* improvement: new instructions section for wallet import page
* improvement: new instructions section for wallet new page
* improvement: new instructions section for network overview page

* refactor: new wallet selection styles and ui (ArkEcosystem#1006)

* fix: do not shake when generating new wallets (ArkEcosystem#1008)

* refactor: success/error colors and delay on clipboard button tooltip (ArkEcosystem#1010)

* refactor: success/error colors and delay on clipboard button tooltip

* misc: use tailwind classes


Co-authored-by: Lúcio Rubens <luciorubeens@gmail.com>

* docs: fix and improve the instructions of how to translate the app (ArkEcosystem#1004)

* feat: adapt the contact creation page to new style (ArkEcosystem#1012)

* refactor: how to infer which background to use on contact new page

* test: adapt the tests

* misc: include the new background for the contact creation page

* feat: add new design to the contact creation page

* refactor: rename contact creation background from `purse.svg` to `wallet.svg`

* refactor: remove unnecessary delegate api calls (ArkEcosystem#995)

* refactor: differentiate between wallet and contact rename (ArkEcosystem#988)

* feat/fix: validation on sign/verify modals & signed messages alignment (ArkEcosystem#1014)

* feat: validation on sign/verify modals

* misc: add :focus color to input icons

* fix: signed message alignment

* refactor: remove nested if branch

* fix: json validation

* misc: update example json format

* feat: different network name style & add ledger flags (ArkEcosystem#991)

* feat: different style for names provided by the network

* fix: show only ledger wallet if address is also watch only wallet

* fix: correct sorting by name if numerical

* refactor: ledger badge in wallet sidebar

* fix: show wallet/contact name

* feat: make whole wallet/contact card clickable

* feat: network name tooltip on wallet/contact grid view

* fix: create contact card alignment

* misc: set hover styles to wallet/contact name on card

* fix: network name tooltip condition

* misc: remove wallet/contact name hover classes

* misc: stop click propagation on card name and balance

* misc: ledger badge styles and tooltip

* fix: sidebar truncation length if ledger

* docs: remove the beta warning and collpase list of commands (ArkEcosystem#1020)

* feat: allow expanding and collapsing the wallet/contact sidebar (ArkEcosystem#1015)

* fix: inconsistencies between network versions (ArkEcosystem#1016)

* fix: transaction fees for v1 networks

* chore: update @arkecosystem/client

* fix: store isHttps for current peer in client

* fix: broadcast tx if no other peers

* refactor: rename method to get peer api version

* fix: check config for core-api excluding prefix(es)

* fix: getters return empty array if no peers

* fix: check peer if v2 to update props, not network

* refactor: get /config from wallet to remove header

* fix: only swap ports on refresh if not already

* test: fix by passing peers in as v2 peers not v1

* fix: set tx timestamp based on network epoch

* fix: sending to single peer if broadcast off

* fix: use 3s timeout when broadcasting to peers

* fix: add forged to delegate model (ArkEcosystem#1017)

* fix: add forged to delegate model

* test: adjust delegate fixtures and tests

* feat: persistent sorting in wallet/contact table (ArkEcosystem#1002)

* feat: persistent sorting in wallet/contact table

* test: add getter & setter tests

* refactor: replace the profile avatars with a new component `ProfileAvatar` (ArkEcosystem#1019)

* refactor: extract the `ProfileAvatar` component from the main sidemenu

* refactor: `ProfileAll` to include `ProfileAvatar`

* fix: avoid breaking the layout and displacing links when the profile balance has 8 decimals

* refactor: extract the `ProfileAvatar` component from the main sidemenu

* refactor: `ProfileAll` to include `ProfileAvatar`

* fix: avoid breaking the layout and displacing links when the profile balance has 8 decimals

* refactor: use the `ProfileAvatar` on the wallets page

* refactor: use the `ProfileAvatar` on the remove profile confirmation

* fix: adjust the position of the avatar on wallet page

* fix: importing of profile avatar selection modal component (ArkEcosystem#1031)

* feat: adapt the contacts page to new design (ArkEcosystem#1007)

* feat: show contact balance on list layout

* feat: adapt the contacts page to the new style

* refactor: increase padding

* fix: increase the font weight of the "i" badge on contact placeholder

* feat: show contact balance on list layout

* feat: adapt the contacts page to the new style

* refactor: increase padding

* fix: increase the font weight of the "i" badge on contact placeholder


Co-authored-by: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com>
Co-authored-by: Lúcio Rubens <luciorubeens@gmail.com>

* refactor: invert identicon hover behaviour (ArkEcosystem#1025)

* feat: add sidebar animation (ArkEcosystem#1021)

* feat: add sidebar animation

* misc: speed up transition

* fix: errors during and after removing profiles (ArkEcosystem#1033)

* fix: do not fail on the profile creation page when removing the last profile

* fix: do not fail at start due not having an active profile

* test: the profile removal confirmation

* fix: avoid errors when removing a profile

* feat: loading screen when broadcasting to many peers (ArkEcosystem#1023)

* fix: don't modify modal loader state

* chore: correct ModalLoder name

* feat: ModalLoader emit closed

* feat: show loader on broadcast to many peers

* fix: timeout when getting peer config

* feat: allow close warning message override

* refactor: update close message for slow broadcasting


Co-authored-by: Juan <j-a-m-l@users.noreply.github.com>

* fix: allow selecting the balance on the wallet page heading (ArkEcosystem#994)

* fix: show "Unvote" action on delegate tab when using Ledger (ArkEcosystem#1032)

* fix: do not fail when voting with Ledger

* fix: show the "Unvote" button at the bottom of the delegate tab when using Ledger wallets

* refactor: new selection design for the network overview (ArkEcosystem#1037)

* change instructions image

* refactor: new selection design for the network overview

* fix: broadcasting modal not closing on unvote (ArkEcosystem#1038)

* chore: update @arkecosystem/client (ArkEcosystem#1036)

* feat: use network static fees as max (ArkEcosystem#1022)

* chore: update @arkecosystem/client to 0.1.19

* feat: client method to fetch static fees

* feat: tx store method to update static fees

* feat: update static fees on peer change

* feat: inputFee component use static if available

* test: fix failing

* test: api client service fetchStaticFees

* test: transaction store with static fees

* docs: jsdoc for new methods

* refactor: store fees against network, not profile

* test: refactor to use network not profile

* fix: update fees when changing peer or custom

* chore: update wallet import and networks pages headings (ArkEcosystem#1039)

* fix: numbers with colon (",") and other formats on the send transfer inputs (ArkEcosystem#1009)

* chore: bump to 2.2.1 (ArkEcosystem#1040)
  • Loading branch information...
luciorubeens committed Jan 29, 2019
1 parent 80fbc65 commit 58d9a7fb138a55043e66dcf737f4bb880a20ecca
Showing with 2,862 additions and 983 deletions.
  1. +11 −8 README.md
  2. +29 −1 __tests__/unit/__fixtures__/services/client.js
  3. +32 −2 __tests__/unit/__fixtures__/store/delegate.js
  4. +16 −0 __tests__/unit/components/Contact/ContactRenameModal.spec.js
  5. +183 −3 __tests__/unit/components/Input/InputCurrency.spec.js
  6. +14 −2 __tests__/unit/components/Input/InputFee.spec.js
  7. +16 −0 __tests__/unit/components/Modal/ModalRename.spec.js
  8. +101 −0 __tests__/unit/components/Profile/ProfileRemovalConfirmation.spec.js
  9. +7 −1 __tests__/unit/components/Wallet/WalletHeadingInfo.spec.js
  10. +16 −0 __tests__/unit/components/Wallet/WalletRenameModal.spec.js
  11. +0 −6 __tests__/unit/pages/Contact/ContactNew.spec.js
  12. +62 −0 __tests__/unit/services/client.spec.js
  13. +134 −0 __tests__/unit/store/modules/delegate.spec.js
  14. +0 −51 __tests__/unit/store/modules/delegates.spec.js
  15. +2 −2 __tests__/unit/store/modules/peer.spec.js
  16. +38 −5 __tests__/unit/store/modules/session.spec.js
  17. +107 −1 __tests__/unit/store/modules/transaction.spec.js
  18. +2 −2 package.json
  19. +1 −0 src/renderer/App.vue
  20. +1 −0 src/renderer/assets/images/networks/add.svg
  21. +76 −0 src/renderer/assets/images/pages/contact-new/wallet.svg
  22. BIN src/renderer/assets/images/pages/network-selection/background-dark.png
  23. BIN src/renderer/assets/images/pages/network-selection/background.png
  24. +1 −0 src/renderer/assets/images/pages/network-selection/background.svg
  25. BIN src/renderer/assets/images/pages/wallet-new/background-step-1-dark.png
  26. BIN src/renderer/assets/images/pages/wallet-new/background-step-1.png
  27. BIN src/renderer/assets/images/pages/wallet-new/background-step-2-dark.png
  28. BIN src/renderer/assets/images/pages/wallet-new/background-step-2.png
  29. BIN src/renderer/assets/images/pages/wallet-new/background-step-3-dark.png
  30. BIN src/renderer/assets/images/pages/wallet-new/background-step-3.png
  31. BIN src/renderer/assets/images/pages/wallet-new/background-step-5-dark.png
  32. BIN src/renderer/assets/images/pages/wallet-new/background-step-5.png
  33. +1 −0 src/renderer/assets/images/pages/wallet-new/backup-wallet.svg
  34. +1 −0 src/renderer/assets/images/pages/wallet-new/choose-wallet.svg
  35. +1 −0 src/renderer/assets/images/pages/wallet-new/encrypt-wallet.svg
  36. +1 −0 src/renderer/assets/images/pages/wallet-new/import-wallet.svg
  37. +1 −0 src/renderer/assets/images/pages/wallet-new/protect-wallet.svg
  38. +1 −0 src/renderer/assets/images/pages/wallet-new/verify-passphrase.svg
  39. +9 −0 src/renderer/assets/svg/collapse.svg
  40. +9 −0 src/renderer/assets/svg/expand.svg
  41. +8 −3 src/renderer/assets/svg/filter.svg
  42. +10 −0 src/renderer/assets/svg/mark-all.svg
  43. +1 −0 src/renderer/assets/svg/settings-filled.svg
  44. +4 −0 src/renderer/assets/svg/sort.svg
  45. +81 −23 src/renderer/components/Announcements/AnnouncementsPost.vue
  46. +21 −29 src/renderer/components/App/AppSidemenu/AppSidemenu.vue
  47. +10 −1 src/renderer/components/Button/ButtonClipboard.vue
  48. +4 −1 src/renderer/components/Button/ButtonLetter.vue
  49. +51 −0 src/renderer/components/Contact/ContactRenameModal.vue
  50. +2 −0 src/renderer/components/Contact/index.js
  51. +1 −1 src/renderer/components/Input/InputAddress.vue
  52. +85 −8 src/renderer/components/Input/InputCurrency.vue
  53. +2 −1 src/renderer/components/Input/InputFee.vue
  54. +2 −1 src/renderer/components/Input/InputGrid/InputGridItem.vue
  55. +1 −1 src/renderer/components/Input/InputGrid/InputGridModal.vue
  56. +1 −1 src/renderer/components/Input/InputPassword.vue
  57. +2 −4 src/renderer/components/ListDivided/ListDividedItem.vue
  58. +17 −6 src/renderer/components/Modal/ModalLoader.vue
  59. +197 −0 src/renderer/components/Modal/ModalRename.vue
  60. +2 −0 src/renderer/components/Modal/index.js
  61. +2 −2 src/renderer/components/Passphrase/PassphraseInput.vue
  62. +47 −0 src/renderer/components/Profile/ProfileAvatar.vue
  63. +34 −7 src/renderer/components/Profile/ProfileRemovalConfirmation.vue
  64. +2 −0 src/renderer/components/Profile/index.js
  65. +10 −27 src/renderer/components/Selection/SelectionNetwork.vue
  66. +90 −0 src/renderer/components/Selection/SelectionNetworkButton.vue
  67. +8 −4 src/renderer/components/Transaction/TransactionForm/TransactionFormDelegateRegistration.vue
  68. +7 −4 src/renderer/components/Transaction/TransactionForm/TransactionFormSecondSignature.vue
  69. +3 −5 src/renderer/components/Transaction/TransactionForm/TransactionFormTransfer.vue
  70. +14 −8 src/renderer/components/Transaction/TransactionForm/TransactionFormVote.vue
  71. +16 −6 src/renderer/components/Transaction/TransactionModal.vue
  72. +15 −19 src/renderer/components/Wallet/WalletDetails/WalletDetails.vue
  73. +18 −10 src/renderer/components/Wallet/WalletHeading/WalletHeadingInfo.vue
  74. +3 −3 src/renderer/components/Wallet/WalletHeading/WalletHeadingPrimaryActions.vue
  75. +11 −2 src/renderer/components/Wallet/WalletHeading/WalletHeadingSecondaryActions.vue
  76. +5 −5 src/renderer/components/Wallet/WalletIdenticon.vue
  77. +13 −138 src/renderer/components/Wallet/WalletRenameModal.vue
  78. +165 −52 src/renderer/components/Wallet/WalletSidebar/WalletSidebar.vue
  79. +15 −0 src/renderer/components/Wallet/WalletSignModal.vue
  80. +12 −8 src/renderer/components/Wallet/WalletSignVerify/WalletSignVerify.vue
  81. +34 −24 src/renderer/components/Wallet/WalletTable.vue
  82. +53 −1 src/renderer/components/Wallet/WalletVerifyModal.vue
  83. +42 −24 src/renderer/i18n/locales/en-US.js
  84. +6 −6 src/renderer/mixins/session.js
  85. +42 −0 src/renderer/models/delegate.js
  86. +8 −0 src/renderer/models/profile.js
  87. +47 −12 src/renderer/pages/Announcements.vue
  88. +125 −86 src/renderer/pages/Contact/ContactAll.vue
  89. +80 −93 src/renderer/pages/Contact/ContactNew.vue
  90. +2 −1 src/renderer/pages/Dashboard.vue
  91. +61 −38 src/renderer/pages/NetworkOverview.vue
  92. +38 −40 src/renderer/pages/Profile/ProfileAll.vue
  93. +1 −1 src/renderer/pages/Profile/ProfileEdition.vue
  94. +107 −60 src/renderer/pages/Wallet/WalletAll.vue
  95. +17 −20 src/renderer/pages/Wallet/WalletImport.vue
  96. +84 −47 src/renderer/pages/Wallet/WalletNew.vue
  97. +22 −1 src/renderer/pages/Wallet/WalletShow.vue
  98. +86 −31 src/renderer/services/client.js
  99. +22 −1 src/renderer/store/modules/delegate.js
  100. +32 −25 src/renderer/store/modules/peer.js
  101. +25 −1 src/renderer/store/modules/session.js
  102. +30 −1 src/renderer/store/modules/transaction.js
  103. +1 −1 src/renderer/styles/_avatars.css
  104. +4 −0 src/renderer/styles/_badges.css
  105. +3 −1 src/renderer/styles/_theme.css
  106. +16 −0 src/renderer/styles/_tooltip.css
  107. +1 −0 src/renderer/styles/style.css
  108. +3 −0 tailwind.js
  109. +5 −4 yarn.lock
@@ -2,12 +2,6 @@

![Ark Desktop Wallet](./banner.png)

## :confetti_ball: Initial release of the all new ARK Desktop Wallet v2 :confetti_ball:

**Note: This is a public beta release. Although the features that are present are expected to be functional and working, it’s still a work in progress and can result in unexpected behaviour. If you find any issues, please open a [GitHub issue](https://github.com/ArkEcosystem/desktop-wallet/issues/new)**

------

[![Build Status](https://badgen.now.sh/circleci/github/ArkEcosystem/desktop-wallet)](https://circleci.com/gh/ArkEcosystem/desktop-wallet)
[![Latest Version](https://badgen.now.sh/github/release/ArkEcosystem/desktop-wallet)](https://github.com/ArkEcosystem/desktop-wallet/releases)
[![License: MIT](https://badgen.now.sh/badge/license/MIT/green)](https://opensource.org/licenses/MIT)
@@ -41,12 +35,17 @@ Translations are part of our [ARK Development and Security Bounty Program](https

Full translations are considered to be `Tier 3`, while grammar fixes, typos, etc. are considered to be `Tier 6`.

Full translations should involve 5 tasks:
<details><summary>Full translations should involve 5 tasks</summary>

- Create a pull request for the language you are going to translate. If you have doubts about something, use English to explain them.
- Translate the textual content of the application, using the [English language file](https://github.com/ArkEcosystem/desktop-wallet/blob/develop/src/renderer/i18n/locales/en-US.js) as the reference. To do that, a new file, with the language locale code should be created. The name of the file should be a valid [RFC 5646](https://tools.ietf.org/html/rfc5646).
- Add the language to the [English language file](https://github.com/ArkEcosystem/desktop-wallet/blob/develop/src/renderer/i18n/locales/en-US.js) at the `LANGUAGES` key.
- Update the [date and time formats file](https://github.com/ArkEcosystem/desktop-wallet/blob/develop/src/renderer/i18n/date-time-formats.js) to include the short and long format that are used commonly by native speakers.
- Update the [number formats file](https://github.com/ArkEcosystem/desktop-wallet/blob/develop/src/renderer/i18n/number-formats.js) to include the preferred way of displaying currencies used commonly by native speakers.
- Add the language at the `I18N.enabledLocales` array at the [main configuration file](https://github.com/ArkEcosystem/desktop-wallet/blob/develop/config/index.js). This step is necessary to make the language would not be available.
- Execute the application. Go to the [ development section](https://github.com/ArkEcosystem/desktop-wallet#development) to learn how to install the requirements and execute it.

</details>

## Development

@@ -75,11 +74,13 @@ npm install -g yarn

### Commands

<details><summary>List of commands</summary>

``` bash
# Install dependencies
yarn install
# Serve the application with hot reload at localhost:9080
# Execute the application. Making changes in the code, updates the application (hot reloading).
yarn dev
# Lint all JS/Vue files in the `src` and `__tests__`
@@ -125,6 +126,8 @@ yarn test:e2e
yarn test:e2e:full
```

</details>

## Security

If you discover a security vulnerability within this project, please send an e-mail to security@ark.io. All security vulnerabilities will be promptly addressed.
@@ -46,7 +46,35 @@ transactions.v1 = [

transactions.v2 = transactions.data

const staticFeeResponses = {
v1: {
fees: {
send: 10000000,
vote: 100000000,
secondsignature: 500000000,
delegate: 2500000000,
multisignature: 500000000
},
success: true
},

v2: {
data: {
transfer: 10000000,
secondSignature: 500000000,
delegateRegistration: 2500000000,
vote: 100000000,
multiSignature: 500000000,
ipfs: 0,
timelockTransfer: 0,
multiPayment: 0,
delegateResignation: 0
}
}
}

export default {
delegates,
transactions
transactions,
staticFeeResponses
}
@@ -1,12 +1,42 @@
const delegate1 = {
username: 'delegate1',
address: 'AKdr5d9AMEnsKYxpDcoHdyyjSCKVx3r9Nj',
publicKey: '020431436cf94f3c6a6ba566fe9e42678db8486590c732ca6c3803a10a86f50b92'
publicKey: '020431436cf94f3c6a6ba566fe9e42678db8486590c732ca6c3803a10a86f50b92',
voteWeight: 4202880284636,
blocks: {
produced: 108940,
missed: 676
},
production: {
productivity: 99.38,
approval: 0.03
},
forged: {
fees: 1173040419815,
rewards: 21788000000000,
total: 22961040419815
},
rank: 59
}
const delegate2 = {
username: 'delegate2',
address: 'AU1TGCYoWzBnGMyMK9GTS8BG6EFbgc5xxC',
publicKey: '02bf72c578a12c35a97ca1230b93017161ee42c3f0ab82f6fe7c95b3b43561a076'
publicKey: '02bf72c578a12c35a97ca1230b93017161ee42c3f0ab82f6fe7c95b3b43561a076',
voteWeight: 2500294939144,
blocks: {
produced: 2497,
missed: 885
},
production: {
productivity: 73.83,
approval: 0.02
},
forged: {
fees: 3085620625,
rewards: 499400000000,
total: 502485620625
},
rank: 62
}

export default [
@@ -0,0 +1,16 @@
import { shallowMount } from '@vue/test-utils'
import useI18nGlobally from '../../__utils__/i18n'
import { ContactRenameModal } from '@/components/Contact'

const i18n = useI18nGlobally()
let wrapper
beforeEach(() => {
wrapper = shallowMount(ContactRenameModal, {
i18n
})
})
describe('ContactRenameModal', () => {
it('should render modal', () => {
expect(wrapper.isVueInstance()).toBeTrue()
})
})
@@ -26,7 +26,8 @@ describe('InputCurrency', () => {
token: 'NET',
market: {
enabled: true
}
},
fractionDigits: 8
}

store.getters['session/network'] = mockNetwork
@@ -40,6 +41,7 @@ describe('InputCurrency', () => {
value: ''
},
mocks: {
currency_format: () => 'NET 9.9',
session_network: mockNetwork
}
}, config))
@@ -55,6 +57,42 @@ describe('InputCurrency', () => {
expect(wrapper.contains('.InputCurrency')).toBeTruthy()
})

describe('decimalSeparator', () => {
it('should be obtained from the locale', () => {
let wrapper = mountComponent({
mocks: {
currency_format: () => 'NET 9.9'
}
})
expect(wrapper.vm.decimalSeparator).toBe('.')

wrapper = mountComponent({
mocks: {
currency_format: () => '9,9 NET'
}
})
expect(wrapper.vm.decimalSeparator).toBe(',')
})
})

describe('thousandSeparator', () => {
it('should be obtained from the locale', () => {
let wrapper = mountComponent({
mocks: {
currency_format: () => 'NET 9.9'
}
})
expect(wrapper.vm.thousandSeparator).toBe(',')

wrapper = mountComponent({
mocks: {
currency_format: () => '9,9 NET'
}
})
expect(wrapper.vm.thousandSeparator).toBe('.')
})
})

describe('when receiving the `isDisabled` prop', () => {
it('should be disabled', () => {
const wrapper = mountComponent({
@@ -92,6 +130,40 @@ describe('InputCurrency', () => {
})
})

describe('emitInput', () => {
it('should emit 0 instead of invalid numbers', () => {
const wrapper = mountComponent()

wrapper.vm.emitInput('not')
expect(wrapper.emitted('input')[0][0]).toEqual(0)

wrapper.vm.emitInput(null)
expect(wrapper.emitted('input')[1][0]).toEqual(0)
})

it('should sanitize the values', () => {
const wrapper = mountComponent()
jest.spyOn(wrapper.vm, 'sanitizeNumeric')

wrapper.vm.emitInput('122,0122')

expect(wrapper.vm.sanitizeNumeric).toHaveBeenCalledWith('122,0122')
})

it('should emit numeric values as Numbers', () => {
const wrapper = mountComponent()

wrapper.vm.emitInput('122,0122')
expect(wrapper.emitted('input')[0][0]).toEqual(122.0122)

wrapper.vm.emitInput('1,,23')
expect(wrapper.emitted('input')[1][0]).toEqual(1.23)

wrapper.vm.emitInput('6,,97')
expect(wrapper.emitted('input')[2][0]).toEqual(6.97)
})
})

describe('checkAmount', () => {
it('should return `true`` on Numbers', () => {
const wrapper = mountComponent()
@@ -109,16 +181,124 @@ describe('InputCurrency', () => {
expect(wrapper.vm.checkAmount('19.9999999999')).toBeTrue()
expect(wrapper.vm.checkAmount('766619.9999999999')).toBeTrue()
expect(wrapper.vm.checkAmount('19,9')).toBeTrue()
expect(wrapper.vm.checkAmount('19,999')).toBeTrue()
expect(wrapper.vm.checkAmount('19,999.00')).toBeTrue()
expect(wrapper.vm.checkAmount('19.999,00')).toBeTrue()
})

it('should return `true` on Strings that could be sanitized as numbers', () => {
const wrapper = mountComponent()

expect(wrapper.vm.checkAmount('.9')).toBeTrue()
expect(wrapper.vm.checkAmount(',95')).toBeTrue()
expect(wrapper.vm.checkAmount(' .79 ')).toBeTrue()
expect(wrapper.vm.checkAmount(' 33')).toBeTrue()
expect(wrapper.vm.checkAmount(' 323 3 3')).toBeTrue()
expect(wrapper.vm.checkAmount('766..999')).toBeTrue()
expect(wrapper.vm.checkAmount('16 4.99')).toBeTrue()
expect(wrapper.vm.checkAmount('7,,36')).toBeTrue()
expect(wrapper.vm.checkAmount('5,,44.3')).toBeTrue()
})

it('should return `false` on Strings that does not look like numbers', () => {
const wrapper = mountComponent()

expect(wrapper.vm.checkAmount('')).toBeFalse()
expect(wrapper.vm.checkAmount('.9')).toBeFalse()
expect(wrapper.vm.checkAmount('a.9')).toBeFalse()
expect(wrapper.vm.checkAmount('19a.99')).toBeFalse()
expect(wrapper.vm.checkAmount('766..999')).toBeFalse()
expect(wrapper.vm.checkAmount('as97')).toBeFalse()
})
})

describe('sanitizeNumeric', () => {
it('should parse numeric values', () => {
const wrapper = mountComponent()

expect(wrapper.vm.sanitizeNumeric('10')).toEqual('10')
expect(wrapper.vm.sanitizeNumeric('1.10')).toEqual('1.10')
expect(wrapper.vm.sanitizeNumeric('.999')).toEqual('0.999')
expect(wrapper.vm.sanitizeNumeric('..87')).toEqual('0.87')
expect(wrapper.vm.sanitizeNumeric(',333')).toEqual('0.333')
expect(wrapper.vm.sanitizeNumeric(',,4')).toEqual('0.4')
expect(wrapper.vm.sanitizeNumeric(' 8')).toEqual('8')
expect(wrapper.vm.sanitizeNumeric('73 ')).toEqual('73')
expect(wrapper.vm.sanitizeNumeric(' 59 ')).toEqual('59')
expect(wrapper.vm.sanitizeNumeric(1.1)).toEqual('1.1')
expect(wrapper.vm.sanitizeNumeric(1e-8)).toEqual('0.00000001')
expect(wrapper.vm.sanitizeNumeric(1e-6)).toEqual('0.000001')
expect(wrapper.vm.sanitizeNumeric('1,1')).toEqual('1.1')
expect(wrapper.vm.sanitizeNumeric('100.200.300,40')).toEqual('100200300.40')
expect(wrapper.vm.sanitizeNumeric('7.777')).toEqual('7.777')
expect(wrapper.vm.sanitizeNumeric('9,999')).toEqual('9999')
expect(wrapper.vm.sanitizeNumeric('9,999,999.99')).toEqual('9999999.99')
expect(wrapper.vm.sanitizeNumeric('10 000 000.5')).toEqual('10000000.5')
expect(wrapper.vm.sanitizeNumeric('30 000.555')).toEqual('30000.555')
expect(wrapper.vm.sanitizeNumeric('80 000,8')).toEqual('80000.8')
expect(wrapper.vm.sanitizeNumeric('30 300,666')).toEqual('30300.666')
expect(wrapper.vm.sanitizeNumeric('11_111_111.11')).toEqual('11111111.11')
expect(wrapper.vm.sanitizeNumeric('33_333,33')).toEqual('33333.33')
expect(wrapper.vm.sanitizeNumeric('10 007')).toEqual('10007')
expect(wrapper.vm.sanitizeNumeric('49,,390.1')).toEqual('49390.1')
expect(wrapper.vm.sanitizeNumeric('1..23')).toEqual('1.23')
expect(wrapper.vm.sanitizeNumeric('6,,19')).toEqual('6.19')
expect(wrapper.vm.sanitizeNumeric('9 8.34')).toEqual('98.34')
})
})

describe('updateInputValue', () => {
describe('when receiving an empty value', () => {
it('should empty the input value', () => {
const wrapper = mountComponent()
wrapper.vm.inputValue = 10

wrapper.vm.updateInputValue('')
expect(wrapper.vm.inputValue).toEqual('')
})

it('should return `true`', () => {
const wrapper = mountComponent()

expect(wrapper.vm.updateInputValue('')).toBeTrue()
})
})

describe('when receiving values that look like numbers', () => {
it('should sanitize it', () => {
const wrapper = mountComponent()
wrapper.vm.inputValue = 1
jest.spyOn(wrapper.vm, 'sanitizeNumeric')

wrapper.vm.updateInputValue('33.333,33')

expect(wrapper.vm.inputValue).toEqual('33333.33')
expect(wrapper.vm.sanitizeNumeric).toHaveBeenCalledWith('33.333,33')
})

it('should return `true`', () => {
const wrapper = mountComponent()

expect(wrapper.vm.updateInputValue('10')).toBeTrue()
})
})

describe('when receiving values that do not look like numbers', () => {
it('should not change the input value', () => {
const wrapper = mountComponent()
wrapper.vm.inputValue = 10

wrapper.vm.updateInputValue('not')
expect(wrapper.vm.inputValue).toEqual(10)

wrapper.vm.updateInputValue(null)
expect(wrapper.vm.inputValue).toEqual(10)
})

it('should return `false`', () => {
const wrapper = mountComponent()

expect(wrapper.vm.updateInputValue('not')).toBeFalse()
expect(wrapper.vm.updateInputValue(null)).toBeFalse()
})
})
})
})

0 comments on commit 58d9a7f

Please sign in to comment.
You can’t perform that action at this time.