1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/app/scripts/controllers/permissions/flask/snap-permissions.test.js
Erik Marks 35ac762e10
Add Snaps via Flask (#13462)
This PR adds `snaps` under Flask build flags to the extension. This branch is mostly equivalent to the current production version of Flask, excepting some bug fixes and tweaks.

Closes #11626
2022-02-14 16:02:51 -08:00

47 lines
1.5 KiB
JavaScript

import {
EndowmentPermissions,
RestrictedMethods,
} from '../../../../../shared/constants/permissions';
import {
buildSnapEndowmentSpecifications,
buildSnapRestrictedMethodSpecifications,
} from './snap-permissions';
describe('buildSnapRestrictedMethodSpecifications', () => {
it('creates valid permission specification objects', () => {
const hooks = {
addSnap: () => undefined,
clearSnapState: () => undefined,
getMnemonic: () => undefined,
getSnap: () => undefined,
getSnapRpcHandler: () => undefined,
getSnapState: () => undefined,
showConfirmation: () => undefined,
updateSnapState: () => undefined,
};
const specifications = buildSnapRestrictedMethodSpecifications(hooks);
const allRestrictedMethods = Object.keys(RestrictedMethods);
Object.keys(specifications).forEach((permissionKey) =>
expect(allRestrictedMethods).toContain(permissionKey),
);
Object.values(specifications).forEach((specification) => {
expect(specification).toMatchObject({
targetKey: expect.stringMatching(/^(snap_|wallet_)/u),
methodImplementation: expect.any(Function),
allowedCaveats: null,
});
});
});
});
describe('buildSnapEndowmentSpecifications', () => {
it('creates valid permission specification objects', () => {
expect(
Object.keys(buildSnapEndowmentSpecifications()).sort(),
).toStrictEqual(Object.keys(EndowmentPermissions).sort());
});
});