mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #6184 from chikeichan/6132
turn camcelCase method name to space separated
This commit is contained in:
commit
1eebe54c64
@ -447,7 +447,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
toName={toName}
|
toName={toName}
|
||||||
toAddress={toAddress}
|
toAddress={toAddress}
|
||||||
showEdit={onEdit && !isTxReprice}
|
showEdit={onEdit && !isTxReprice}
|
||||||
action={action || name || this.context.t('contractInteraction')}
|
action={action || getMethodName(name) || this.context.t('contractInteraction')}
|
||||||
title={title}
|
title={title}
|
||||||
titleComponent={this.renderTitleComponent()}
|
titleComponent={this.renderTitleComponent()}
|
||||||
subtitle={subtitle}
|
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, ' ')
|
||||||
|
}
|
||||||
|
@ -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')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user