You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
3 years ago
|
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());
|
||
|
});
|
||
|
});
|