@shko.online/componentframework-mock
Version:
Mocking library to help with testing PowerApps Component Framework Components
36 lines (35 loc) • 1.17 kB
JavaScript
/*
Copyright (c) 2022 Betim Beja and Shko Online LLC
Licensed under the MIT license.
*/
import { stub } from 'sinon';
export class UtilityMock {
constructor() {
this.getEntityMetadata = void 0;
this.hasEntityPrivilege = void 0;
this.lookupObjects = void 0;
this.loadDependency = void 0;
this.getEntityMetadata = stub();
this.hasEntityPrivilege = stub();
this.hasEntityPrivilege.callsFake((entityTypeName, privilegeType, privilegeDepth) => {
return true;
});
this.lookupObjects = stub();
this.lookupObjects.callsFake(lookupOptions => {
return new Promise(resolve => {
setTimeout(() => resolve([{
entityType: lookupOptions.entityTypes ? lookupOptions.entityTypes[0] : 'mocked_entity',
id: '00000000-0000-0000-0000-000000000001',
name: 'Fake Lookup Result'
}]));
});
});
this.loadDependency = stub();
this.loadDependency.callsFake(dependencyName => {
return new Promise(resolve => {
setTimeout(() => resolve({}) // the platform returns the control class when found or undefined when not found.
);
});
});
}
}