UNPKG

@shko.online/componentframework-mock

Version:

Mocking library to help with testing PowerApps Component Framework Components

21 lines (20 loc) 820 B
/* Copyright (c) 2022 Betim Beja and Shko Online LLC Licensed under the MIT license. */ export 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) { var _result$Attributes; result.Attributes = (_result$Attributes = result.Attributes) === null || _result$Attributes === void 0 ? void 0 : _result$Attributes.filter(attribute => attributes.some(attributeFilter => attribute.LogicalName === attributeFilter)); } resolve(result); }); }); };