mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
a52c6a4908
* Bump snaps-skunkworks to 0.19.0 * Improve snap_getBip32Entropy UI * Remove console.log * Update LavaMoat policy * Dedupe Yarn lock * Update LavaMoat policy again * Fix tests * Update policies and e2e tests * Update policy again * Update iframe-execution-environment * Dedupe yarn.lock * Update snapshots * Fix PR comments * Add TODO * Trigger CI
46 lines
1.4 KiB
JavaScript
46 lines
1.4 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),
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('buildSnapEndowmentSpecifications', () => {
|
|
it('creates valid permission specification objects', () => {
|
|
expect(
|
|
Object.keys(buildSnapEndowmentSpecifications()).sort(),
|
|
).toStrictEqual(Object.keys(EndowmentPermissions).sort());
|
|
});
|
|
});
|