UNPKG

@shko.online/componentframework-mock

Version:

Mocking library to help with testing PowerApps Component Framework Components

27 lines (25 loc) 862 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mockGetEntityMetadata = void 0; /* Copyright (c) 2022 Betim Beja and Shko Online LLC Licensed under the MIT license. */ const mockGetEntityMetadata = mockGenerator => { mockGenerator.context.utils.getEntityMetadata.callsFake((entityName, attributes) => { return new Promise((resolve, reject) => { const result = mockGenerator.metadata.getTableMetadata(entityName); if (!result) { reject(`Could not find entity metadata for '${entityName}'`); return; } if (attributes) { result.Attributes = result.Attributes?.filter(attribute => attributes.some(attributeFilter => attribute.LogicalName === attributeFilter)); } resolve(result); }); }); }; exports.mockGetEntityMetadata = mockGetEntityMetadata;