diff options
author | Thomas <tmashuang@gmail.com> | 2018-04-19 02:26:49 +0800 |
---|---|---|
committer | Thomas <tmashuang@gmail.com> | 2018-04-19 02:26:49 +0800 |
commit | 30df8b7995c61ce1ede06f9caef5c507fb678ddd (patch) | |
tree | 9b82f4ecf9da28673211f6e5c88cb240c43ee038 | |
parent | f82c51c2c4782f54fb1d690f2dc1c309fafefe65 (diff) | |
download | tangerine-wallet-browser-30df8b7995c61ce1ede06f9caef5c507fb678ddd.tar.gz tangerine-wallet-browser-30df8b7995c61ce1ede06f9caef5c507fb678ddd.tar.zst tangerine-wallet-browser-30df8b7995c61ce1ede06f9caef5c507fb678ddd.zip |
newUnsignedMessage and newUnsignedPersonalMessage
-rw-r--r-- | test/unit/metamask-controller-test.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js index 454b0ae44..52b67fdf6 100644 --- a/test/unit/metamask-controller-test.js +++ b/test/unit/metamask-controller-test.js @@ -33,6 +33,7 @@ describe('MetaMaskController', function () { metamaskController = new MetaMaskController({ showUnapprovedTx: noop, + showUnconfirmedMessage: noop, encryptor: { encrypt: function (password, object) { this.object = object @@ -298,4 +299,105 @@ describe('MetaMaskController', function () { }) + describe('#setCurrentLocale', function () { + + it('checks the default currentLocale', function () { + const preferenceCurrentLocale = metamaskController.preferencesController.store.getState().currentLocale + assert.equal(preferenceCurrentLocale, undefined) + }) + + it('sets current locale in preferences controller', function () { + metamaskController.setCurrentLocale('ja', noop) + const preferenceCurrentLocale = metamaskController.preferencesController.store.getState().currentLocale + assert.equal(preferenceCurrentLocale, 'ja') + }) + + }) + + describe('#newUnsignedMessage', function () { + + let msgParams, metamaskMsgs, messages, msgId + + const address = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' + const data = '0x43727970746f6b697474696573' + + beforeEach(function () { + + msgParams = { + 'from': address, + 'data': data, + } + + metamaskController.newUnsignedMessage(msgParams, noop) + metamaskMsgs = metamaskController.messageManager.getUnapprovedMsgs() + messages = metamaskController.messageManager.messages + msgId = Object.keys(metamaskMsgs)[0] + }) + + it('persists address from msg params', function () { + assert.equal(metamaskMsgs[msgId].msgParams.from, address) + }) + + it('persists data from msg params', function () { + assert.equal(metamaskMsgs[msgId].msgParams.data, data) + }) + + it('sets the status to unapproved', function () { + assert.equal(metamaskMsgs[msgId].status, 'unapproved') + }) + + it('sets the type to eth_sign', function () { + assert.equal(metamaskMsgs[msgId].type, 'eth_sign') + }) + + it('rejects the message', function () { + const msgIdInt = parseInt(msgId) + metamaskController.cancelMessage(msgIdInt, noop) + assert.equal(messages[0].status, 'rejected') + }) + }) + + describe('#newUnsignedPersonalMessage', function () { + + let msgParams, metamaskMsgs, messages, msgId + + const address = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' + const data = '0x43727970746f6b697474696573' + + beforeEach(function () { + + msgParams = { + 'from': address, + 'data': data, + } + + metamaskController.newUnsignedPersonalMessage(msgParams, noop) + metamaskMsgs = metamaskController.personalMessageManager.getUnapprovedMsgs() + messages = metamaskController.personalMessageManager.messages + msgId = Object.keys(metamaskMsgs)[0] + }) + + it('persists address from msg params', function () { + assert.equal(metamaskMsgs[msgId].msgParams.from, address) + }) + + it('persists data from msg params', function () { + assert.equal(metamaskMsgs[msgId].msgParams.data, data) + }) + + it('sets the status to unapproved', function () { + assert.equal(metamaskMsgs[msgId].status, 'unapproved') + }) + + it('sets the type to personal_sign', function () { + assert.equal(metamaskMsgs[msgId].type, 'personal_sign') + }) + + it('rejects the message', function () { + const msgIdInt = parseInt(msgId) + metamaskController.cancelPersonalMessage(msgIdInt, noop) + assert.equal(messages[0].status, 'rejected') + }) + }) + }) |