@shko.online/componentframework-mock
Version:
Mocking library to help with testing PowerApps Component Framework Components
48 lines (47 loc) • 1.37 kB
JavaScript
/*
Copyright (c) 2022 Betim Beja and Shko Online LLC
Licensed under the MIT license.
*/
import { stub } from 'sinon';
export 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 = stub();
this.get = stub();
this.get.callsFake(logicalName => {
return this._attributes.find(attribute => attribute.LogicalName === logicalName);
});
this.getAll = stub();
this.getAll.callsFake(() => {
return this._attributes;
});
this.getByFilter = stub();
this.getByName = stub();
this.getByName.callsFake(logicalName => {
return this._attributes.find(attribute => attribute.LogicalName === logicalName);
});
this.getByIndex = stub();
this.getByIndex.callsFake(index => {
return this._attributes[index];
});
this.getFirst = stub();
this.getFirst.callsFake(lambda => {
return this._attributes.find(lambda);
});
this.getLength = stub();
this.getLength.callsFake(() => {
return this._attributes.length;
});
this.remove = stub();
}
}