UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

77 lines (76 loc) • 2.57 kB
import GirafeConfig from '../configuration/girafeconfig'; import { MockConfig } from './mockconfig'; import ContextInitializationHelper from '../context/contexthelper'; export default class MockGirafeContext { userDataManager; configManager; stateManager; componentManager; userInteractionManager; i18nManager; pluginManager; themesManager; themesHelper; permalinkManager; dragManager; urlManager; layerManager; sessionManager; stateSerializer; shareManager; customThemesManager; errorManager; wfsManager; authManager; snapManager; mapManager; logManager; offlineManager; applicationLifeCycleManager; orderingManager; userLayerManager; wmsManager; wmtsManager; selectionManager; ogcApiFeaturesManager; localFileManager; onBoardingManager; themeFavoritesManager; searchManager; feedbackManager; contextHelper = new ContextInitializationHelper(); constructor() { this.contextHelper.constructContext(this); } async initialize() { await this.contextHelper.initializeContext(this); } /** The context can contains hook methods that will be called after each manager initialization. * The hook method must be named with the property name + the "Hook" suffix. * The hook method must be async and will be awaited * For example, the methods themesManagerHook() will be called immediately after * the call of themesManager.initializeSingleton(). * This allows specific initialization methods when defining custom contexts * (for example for the apiContext, the mockContext, or any customContext) */ async userDataManagerHook() { await this.userDataManager.initializeSingleton(); this.userDataManager.initializeFromConfig(MockConfig.userdata); await this.userDataManager.deleteAllUserData(); } async configManagerHook() { // Do not call the initializeSingleton methode // But set hardcoded mock config // @ts-ignore this.configManager['config'] = new GirafeConfig(MockConfig); // @ts-ignore this.configManager['defaultConfig'] = new GirafeConfig(MockConfig); } async i18nManagerHook() { // Do not load translation files // Bu set hardcoded mock translations await this.i18nManager.initializeSingleton(); // @ts-expect-error: private property this.i18nManager.translations = { fr: { a: 'translated_a', b: 'translated_b' } }; } }