1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-26 13:20:26 +02:00
metamask-extension/test/unit/app/controllers/permissions/restricted-methods-test.js
Erik Marks b1d090ac4d
Add permissions controller unit tests (#7969)
* add permissions controller, log, middleware, and restricted method unit tests

* fix permissions-related bugs

* convert permissions log to controller-like class

* add permissions unit test coverage requirements

* update rpc-cap

Co-Authored-By: Whymarrh Whitby <whymarrh.whitby@gmail.com>
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2020-03-16 10:13:22 -07:00

36 lines
901 B
JavaScript

import { strict as assert } from 'assert'
import getRestrictedMethods
from '../../../../../app/scripts/controllers/permissions/restrictedMethods'
describe('restricted methods', function () {
// this method is tested extensively in other permissions tests
describe('eth_accounts', function () {
it('handles failure', async function () {
const restrictedMethods = getRestrictedMethods({
getKeyringAccounts: async () => {
throw new Error('foo')
},
})
const res = {}
restrictedMethods.eth_accounts.method(null, res, null, (err) => {
const fooError = new Error('foo')
assert.deepEqual(
err, fooError,
'should end with expected error'
)
assert.deepEqual(
res, { error: fooError },
'response should have expected error and no result'
)
})
})
})
})