UNPKG

passbolt-styleguide

Version:

Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.

99 lines (92 loc) 3.36 kB
/** * Passbolt ~ Open source password manager for teams * Copyright (c) Passbolt SA (https://www.passbolt.com) * * Licensed under GNU Affero General Public License version 3 of the or any later version. * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Passbolt SA (https://www.passbolt.com) * @license https://opensource.org/licenses/AGPL-3.0 AGPL License * @link https://www.passbolt.com Passbolt(tm) * @since 4.1.0 */ import RbacsCollection from "../../../../shared/models/entity/rbac/rbacsCollection"; import RolesCollection from "../../../../shared/models/entity/role/rolesCollection"; import { rolesCollectionDto } from "../../../../shared/models/entity/role/rolesCollection.test.data"; import { settingsRbacsCollectionData, settingsRbacsCollectionFromRoleCollectionData, } from "../../../../shared/models/entity/rbac/rbacsCollection.test.data"; import { defaultAppContext } from "../../ApiAppContext.test.data"; /** * Default props. * @returns {object} * @param data */ export function defaultProps(data = {}) { const defaultProps = { context: defaultAppContext(data?.context), adminRbacContext: defaultAdministrationRbacContext, }; return Object.assign(defaultProps, data); } /** * Returns the default administration rbac context for the unit test * @param context An existing administration context * @returns {object} */ export function defaultAdministrationRbacContext(context = {}) { return { rbacs: null, roles: null, rbacsUpdated: new RbacsCollection([]), setRbacs: jest.fn(), isProcessing: jest.fn(), setRbacsUpdated: jest.fn(), updateRbacControlFunction: jest.fn(), clearContext: jest.fn(), save: jest.fn(), hasSettingsChanges: jest.fn(), ...context, }; } /** * Returns a populated version of administration rbac context for the unit test * @param context An existing administration context * @returns {object} */ export function populatedAdministrationRbacContext(context = {}) { const rolesCollection = rolesCollectionDto; return defaultAdministrationRbacContext({ rbacs: new RbacsCollection(settingsRbacsCollectionFromRoleCollectionData(rolesCollection)), roles: new RolesCollection(rolesCollection), ...context, }); } /** * Returns a populated version of administration rbac context with missing Rbac elements for the unit test * @param context An existing administration context * @returns {object} */ export function populatedAdministrationWithMissingRbacContext(context = {}) { return defaultAdministrationRbacContext({ rbacs: new RbacsCollection(settingsRbacsCollectionData()), roles: new RolesCollection(rolesCollectionDto), ...context, }); } /** * Returns a populated version of administration rbac context with updated rbacs settings for the unit test * @param context An existing administration context * @returns {object} */ export function administrationRbacContextWithUpdatedRbac(context = {}) { const rbacs = new RbacsCollection(settingsRbacsCollectionData()); const rbacsUpdated = new RbacsCollection([rbacs.items[3], rbacs.items[7]]); return populatedAdministrationRbacContext({ rbacs, rbacsUpdated, ...context, }); }