UNPKG

@shko.online/componentframework-mock

Version:

Mocking library to help with testing PowerApps Component Framework Components

55 lines (53 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AttributeMetadataCollection = void 0; var _sinon = require("sinon"); /* Copyright (c) 2022 Betim Beja and Shko Online LLC Licensed under the MIT license. */ class AttributeMetadataCollection { constructor(attributes) { this._attributes = void 0; this.add = void 0; this.get = void 0; this.getAll = void 0; this.getByFilter = void 0; this.getByName = void 0; this.getByIndex = void 0; this.getFirst = void 0; this.getLength = void 0; this.remove = void 0; this._attributes = attributes; this.add = (0, _sinon.stub)(); this.get = (0, _sinon.stub)(); this.get.callsFake(logicalName => { return this._attributes.find(attribute => attribute.LogicalName === logicalName); }); this.getAll = (0, _sinon.stub)(); this.getAll.callsFake(() => { return this._attributes; }); this.getByFilter = (0, _sinon.stub)(); this.getByName = (0, _sinon.stub)(); this.getByName.callsFake(logicalName => { return this._attributes.find(attribute => attribute.LogicalName === logicalName); }); this.getByIndex = (0, _sinon.stub)(); this.getByIndex.callsFake(index => { return this._attributes[index]; }); this.getFirst = (0, _sinon.stub)(); this.getFirst.callsFake(lambda => { return this._attributes.find(lambda); }); this.getLength = (0, _sinon.stub)(); this.getLength.callsFake(() => { return this._attributes.length; }); this.remove = (0, _sinon.stub)(); } } exports.AttributeMetadataCollection = AttributeMetadataCollection;