diff options
author | Dan J Miller <danjm.com@gmail.com> | 2019-02-20 08:29:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-20 08:29:43 +0800 |
commit | 1eebe54c6422845ec90e6bdb8bffc7c1a7da440c (patch) | |
tree | 23edf999ca374e9ad6b60ed54d381f01bc52f11d | |
parent | cbcaf87998db077bb6aa8703214ebee9a0f0541b (diff) | |
parent | 7be47952578357d70c71bc10958febcdc58f7c17 (diff) | |
download | tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar.gz tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar.bz2 tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar.lz tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar.xz tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.tar.zst tangerine-wallet-browser-1eebe54c6422845ec90e6bdb8bffc7c1a7da440c.zip |
Merge pull request #6184 from chikeichan/6132
turn camcelCase method name to space separated
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') + }) + }) +}) |