From 50d91f998d0dc228c1d5dac7966df89d6c3fe6c4 Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Thu, 4 Oct 2018 19:26:41 -0700 Subject: Translate method names in the transaction list only when applicable --- ui/app/helpers/common.util.js | 5 +++++ ui/app/helpers/tests/common.util.test.js | 23 +++++++++++++++++++++++ ui/app/helpers/transactions.util.js | 2 -- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 ui/app/helpers/common.util.js create mode 100644 ui/app/helpers/tests/common.util.test.js (limited to 'ui/app/helpers') diff --git a/ui/app/helpers/common.util.js b/ui/app/helpers/common.util.js new file mode 100644 index 000000000..d4acb9968 --- /dev/null +++ b/ui/app/helpers/common.util.js @@ -0,0 +1,5 @@ +export function camelCaseToCapitalize (str) { + return str + .replace(/([A-Z])/g, ' $1') + .replace(/^./, str => str.toUpperCase()) +} diff --git a/ui/app/helpers/tests/common.util.test.js b/ui/app/helpers/tests/common.util.test.js new file mode 100644 index 000000000..891e19ef5 --- /dev/null +++ b/ui/app/helpers/tests/common.util.test.js @@ -0,0 +1,23 @@ +import * as utils from '../common.util' +import assert from 'assert' + +describe('Common utils', () => { + describe('camelCaseToCapitalize', () => { + it('should return a capitalized string from a camel-cased string', () => { + const tests = [ + { + test: '', + expected: '', + }, + { + test: 'thisIsATest', + expected: 'This Is A Test', + }, + ] + + tests.forEach(({ test, expected }) => { + assert.equal(utils.camelCaseToCapitalize(test), expected) + }) + }) + }) +}) diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index 8b87bb538..fdad63a96 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -80,8 +80,6 @@ export async function getTransactionActionKey (transaction, methodData) { return APPROVE_ACTION_KEY case TOKEN_METHOD_TRANSFER_FROM: return TRANSFER_FROM_ACTION_KEY - default: - return name } } else { return SEND_ETHER_ACTION_KEY -- cgit