UNPKG

@shopware-ag/meteor-admin-sdk

Version:

The Meteor SDK for the Shopware Administration.

53 lines 2.54 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import createACLHelper from './acl'; describe('createACLHelper', () => { it('returns true if the crud privilege is granted', () => __awaiter(void 0, void 0, void 0, function* () { const mockGetAppInformation = jest.fn().mockResolvedValue({ privileges: { read: ['product'], }, }); const can = createACLHelper(mockGetAppInformation); const result = yield can('product:read'); expect(result).toBe(true); })); it('returns false if the crud privilege is not granted', () => __awaiter(void 0, void 0, void 0, function* () { const mockGetAppInformation = jest.fn().mockResolvedValue({ privileges: { read: ['product'], }, }); const can = createACLHelper(mockGetAppInformation); const result = yield can('order:read'); expect(result).toBe(false); })); it('returns true if the additional privilege is granted', () => __awaiter(void 0, void 0, void 0, function* () { const mockGetAppInformation = jest.fn().mockResolvedValue({ privileges: { additional: ['api_service_toggle'], }, }); const can = createACLHelper(mockGetAppInformation); const result = yield can('api_service_toggle'); expect(result).toBe(true); })); it('returns false if the additional privilege is not granted', () => __awaiter(void 0, void 0, void 0, function* () { const mockGetAppInformation = jest.fn().mockResolvedValue({ privileges: { additional: ['system.plugin_maintain'] }, }); const can = createACLHelper(mockGetAppInformation); const result = yield can('order:read'); expect(result).toBe(false); })); }); //# sourceMappingURL=acl.spec.js.map