mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
51cffa15dd
* Migrate to new controller packages `@metamask/controllers` is deprecated, and most of the controllers that lived here are now located in their own package ([1]). This commit replaces `@metamask/controllers` in `package.json` with references to these packages and updates `import` lines to match. [1]: https://github.com/MetaMask/controllers/pull/831 * Support GitHub registry for draft PRs (#16549) * Add additional allowed host to lockfile linter * Update LavaMoat policies * Add policy exception for nanoid * Add additional nanoid overrides * Update LavaMoat policies again * Bump controller packages * Update lavamoat * Bump controller packages * Update packages to v1.0.0 * Expand gitignore comment * Unpin controller dependencies, using ^ range instead Co-authored-by: Mark Stacey <markjstacey@gmail.com>
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import { CaveatMutatorOperation } from '@metamask/permission-controller';
|
|
import { CaveatTypes } from '../../../../shared/constants/permissions';
|
|
import { CaveatMutatorFactories } from './caveat-mutators';
|
|
|
|
describe('caveat mutators', () => {
|
|
describe('restrictReturnedAccounts', () => {
|
|
const { removeAccount } =
|
|
CaveatMutatorFactories[CaveatTypes.restrictReturnedAccounts];
|
|
|
|
describe('removeAccount', () => {
|
|
it('returns the no-op operation if the target account is not permitted', () => {
|
|
expect(removeAccount('0x2', ['0x1'])).toStrictEqual({
|
|
operation: CaveatMutatorOperation.noop,
|
|
});
|
|
});
|
|
|
|
it('returns the update operation and a new value if the target account is permitted', () => {
|
|
expect(removeAccount('0x2', ['0x1', '0x2'])).toStrictEqual({
|
|
operation: CaveatMutatorOperation.updateValue,
|
|
value: ['0x1'],
|
|
});
|
|
});
|
|
|
|
it('returns the revoke permission operation the target account is the only permitted account', () => {
|
|
expect(removeAccount('0x1', ['0x1'])).toStrictEqual({
|
|
operation: CaveatMutatorOperation.revokePermission,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|