UNPKG

@shko.online/componentframework-mock

Version:

Mocking library to help with testing PowerApps Component Framework Components

20 lines (19 loc) 694 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) { result.Attributes = result.Attributes?.filter(attribute => attributes.some(attributeFilter => attribute.LogicalName === attributeFilter)); } resolve(result); }); }); };