UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

65 lines 3.2 kB
import { __extends } from "tslib"; import { DisplayMode, ServiceScope, SPEvent } from '@microsoft/sp-core-library'; import { WebPartContext, WebPartFormFactor } from '../index'; // <-- part of "test-api" pattern; see sp-build-internal-web/includes/test-api-pattern/README.md import MockWebPartManifestInstance from './MockWebPartManifestInstance'; var MockWebPartContextParameters = /** @class */ (function () { function MockWebPartContextParameters() { this.domElement = document.createElement('div'); this.manifest = new MockWebPartManifestInstance(); this.instanceId = 'wpInstanceId'; this.webPartTag = 'WebPart.daf0b71c-6de8-4ef7-b511-faae7c388708.0ae4973a-70e3-451e-9f1f-3f25e5455a60'; this.loggingTag = 'WebPart.daf0b71c-6de8-4ef7-b511-faae7c388708.0ae4973a-70e3-451e-9f1f-3f25e5455a60'; this.sdks = {}; this.sdksAsync = Promise.resolve({}); // eslint-disable-next-line @typescript-eslint/no-explicit-any this.httpClient = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any this.spHttpClient = {}; this.parentServiceScope = ServiceScope.startNewRoot(); // public serviceScope: ServiceScope = this.parentServiceScope.startNewChild(); // public pageContext: PageContext = new PageContext(this.parentServiceScope); // eslint-disable-next-line @typescript-eslint/no-explicit-any this.statusRenderer = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any this.host = {}; this.formFactor = WebPartFormFactor.Standard; this.propertyPane = { open: function () { /* no-op */ }, refresh: function () { /* no-op */ } // eslint-disable-next-line @typescript-eslint/no-explicit-any }; this._dataUpdatedEvent = new SPEvent('webPart_exampleInstanceId_dataUpdated'); this.isPropertyPaneRenderedByWebPart = function () { return true; }; this.isPropertyPaneOpen = function () { return false; }; this.isContentPanelOpen = function () { return false; }; this.requestPropertyPaneAction = function () { }; } return MockWebPartContextParameters; }()); export { MockWebPartContextParameters }; var MockWebPartContext = /** @class */ (function (_super) { __extends(MockWebPartContext, _super); function MockWebPartContext(parameters) { return _super.call(this, parameters) || this; } /** * Simulates initialization of the web part, equivalent to what the ClientSideWebPartManager * would do. */ MockWebPartContext.prototype.initialize = function (webPart) { var parentServiceScope = this.serviceScope.getParent(); if (parentServiceScope) { parentServiceScope.finish(); } // eslint-disable-next-line @typescript-eslint/no-explicit-any webPart._internalInitialize(this, false /* addedFromPersistedData */, DisplayMode.Read); return webPart; }; return MockWebPartContext; }(WebPartContext)); export default MockWebPartContext; //# sourceMappingURL=MockWebPartContext.js.map