@microsoft/sp-webpart-base
Version:
SharePoint Framework support for building web parts
68 lines • 3.43 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockWebPartContextParameters = void 0;
var tslib_1 = require("tslib");
var sp_core_library_1 = require("@microsoft/sp-core-library");
var index_1 = require("../index"); // <-- part of "test-api" pattern; see sp-build-internal-web/includes/test-api-pattern/README.md
var MockWebPartManifestInstance_1 = tslib_1.__importDefault(require("./MockWebPartManifestInstance"));
var MockWebPartContextParameters = /** @class */ (function () {
function MockWebPartContextParameters() {
this.domElement = document.createElement('div');
this.manifest = new MockWebPartManifestInstance_1.default();
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 = sp_core_library_1.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 = index_1.WebPartFormFactor.Standard;
this.propertyPane = {
open: function () {
/* no-op */
},
refresh: function () {
/* no-op */
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
};
this._dataUpdatedEvent = new sp_core_library_1.SPEvent('webPart_exampleInstanceId_dataUpdated');
this.isPropertyPaneRenderedByWebPart = function () { return true; };
this.isPropertyPaneOpen = function () { return false; };
this.isContentPanelOpen = function () { return false; };
this.requestPropertyPaneAction = function () { };
}
return MockWebPartContextParameters;
}());
exports.MockWebPartContextParameters = MockWebPartContextParameters;
var MockWebPartContext = /** @class */ (function (_super) {
tslib_1.__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 */, sp_core_library_1.DisplayMode.Read);
return webPart;
};
return MockWebPartContext;
}(index_1.WebPartContext));
exports.default = MockWebPartContext;
//# sourceMappingURL=MockWebPartContext.js.map