diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2019-02-19 13:36:12 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2019-02-19 13:36:12 +0800 |
commit | 7be47952578357d70c71bc10958febcdc58f7c17 (patch) | |
tree | b1d4ce1454caed3f2ab14f4b3a4db882a77355fd /ui/app | |
parent | 89c43534082b920f68503eddc1dd3cc8f16aeb17 (diff) | |
download | tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar.gz tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar.bz2 tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar.lz tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar.xz tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.tar.zst tangerine-wallet-browser-7be47952578357d70c71bc10958febcdc58f7c17.zip |
turn camcelCase method name to space separated
Diffstat (limited to 'ui/app')
2 files changed, 26 insertions, 1 deletions
diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js index d99f03308..f3d17e105 100644 --- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -447,7 +447,7 @@ export default class ConfirmTransactionBase extends Component { toName={toName} toAddress={toAddress} showEdit={onEdit && !isTxReprice} - action={action || name || this.context.t('contractInteraction')} + action={action || getMethodName(name) || this.context.t('contractInteraction')} title={title} titleComponent={this.renderTitleComponent()} subtitle={subtitle} @@ -483,3 +483,14 @@ export default class ConfirmTransactionBase extends Component { ) } } + +export function getMethodName (camelCase) { + if (!camelCase || typeof camelCase !== 'string') { + return '' + } + + return camelCase + .replace(/([a-z])([A-Z])/g, '$1 $2') + .replace(/([A-Z])([a-z])/g, ' $1$2') + .replace(/ +/g, ' ') +} diff --git a/ui/app/components/pages/confirm-transaction-base/tests/confirm-transaction-base.component.test.js b/ui/app/components/pages/confirm-transaction-base/tests/confirm-transaction-base.component.test.js new file mode 100644 index 000000000..8ca7ca4e7 --- /dev/null +++ b/ui/app/components/pages/confirm-transaction-base/tests/confirm-transaction-base.component.test.js @@ -0,0 +1,14 @@ +import assert from 'assert' +import { getMethodName } from '../confirm-transaction-base.component' + +describe('ConfirmTransactionBase Component', () => { + describe('getMethodName', () => { + it('should get correct method names', () => { + assert.equal(getMethodName(undefined), '') + assert.equal(getMethodName({}), '') + assert.equal(getMethodName('confirm'), 'confirm') + assert.equal(getMethodName('balanceOf'), 'balance Of') + assert.equal(getMethodName('ethToTokenSwapInput'), 'eth To Token Swap Input') + }) + }) +}) |