Vmeda.Online/src/core/initializers/prepare-automated-tests.ts

50 lines
2.0 KiB
TypeScript
Raw Normal View History

// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2021-10-04 17:14:45 +02:00
import { ApplicationRef, NgZone as NgZoneService } from '@angular/core';
import { CorePushNotifications, CorePushNotificationsProvider } from '@features/pushnotifications/services/pushnotifications';
import { CoreApp, CoreAppProvider } from '@services/app';
import { CoreCronDelegate, CoreCronDelegateService } from '@services/cron';
import { CoreDB, CoreDbProvider } from '@services/db';
2021-06-10 14:55:32 +02:00
import { CoreCustomURLSchemes, CoreCustomURLSchemesProvider } from '@services/urlschemes';
2021-10-04 17:14:45 +02:00
import { Application, NgZone } from '@singletons';
type AutomatedTestsWindow = Window & {
appRef?: ApplicationRef;
appProvider?: CoreAppProvider;
dbProvider?: CoreDbProvider;
cronProvider?: CoreCronDelegateService;
2021-10-04 17:14:45 +02:00
ngZone?: NgZoneService;
pushNotifications?: CorePushNotificationsProvider;
2021-06-10 14:55:32 +02:00
urlSchemes?: CoreCustomURLSchemesProvider;
};
function initializeAutomatedTestsWindow(window: AutomatedTestsWindow) {
window.appRef = Application.instance;
window.appProvider = CoreApp.instance;
window.dbProvider = CoreDB.instance;
window.cronProvider = CoreCronDelegate.instance;
2021-10-04 17:14:45 +02:00
window.ngZone = NgZone.instance;
window.pushNotifications = CorePushNotifications.instance;
2021-06-10 14:55:32 +02:00
window.urlSchemes = CoreCustomURLSchemes.instance;
}
export default function(): void {
if (!CoreAppProvider.isAutomated()) {
return;
}
initializeAutomatedTestsWindow(window);
}