UNPKG

@shko.online/componentframework-mock

Version:

Mocking library to help with testing PowerApps Component Framework Components

43 lines (41 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UtilityMock = void 0; var _sinon = require("sinon"); /* Copyright (c) 2022 Betim Beja and Shko Online LLC Licensed under the MIT license. */ class UtilityMock { constructor() { this.getEntityMetadata = void 0; this.hasEntityPrivilege = void 0; this.lookupObjects = void 0; this.loadDependency = void 0; this.getEntityMetadata = (0, _sinon.stub)(); this.hasEntityPrivilege = (0, _sinon.stub)(); this.hasEntityPrivilege.callsFake((entityTypeName, privilegeType, privilegeDepth) => { return true; }); this.lookupObjects = (0, _sinon.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 = (0, _sinon.stub)(); this.loadDependency.callsFake(dependencyName => { return new Promise(resolve => { setTimeout(() => resolve({}) // the platform returns the control class when found or undefined when not found. ); }); }); } } exports.UtilityMock = UtilityMock;