[SI-1737] unit tests added

Signed-off-by: Peter Buschmann <peter.buschmann@pta.de>
diff --git a/projects/grid-failure-information-map-app/src/app/app-config.service.spec.ts b/projects/grid-failure-information-map-app/src/app/app-config.service.spec.ts
index f20c483..de478d0 100644
--- a/projects/grid-failure-information-map-app/src/app/app-config.service.spec.ts
+++ b/projects/grid-failure-information-map-app/src/app/app-config.service.spec.ts
@@ -11,18 +11,30 @@
  * SPDX-License-Identifier: EPL-2.0
  ********************************************************************************/
 import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
-import { HttpClient } from '@angular/common/http';
 
 describe('AppConfigService', () => {
   let service: AppConfigService;
-  let http: HttpClient;
+  let mockHttpClient;
   let baseHref: string;
 
   beforeEach(() => {
-    service = new AppConfigService(http, baseHref);
+    mockHttpClient = { get: () => {} };
+    service = new AppConfigService(mockHttpClient, baseHref);
   });
 
   it('should be created', () => {
     expect(service).toBeTruthy();
   });
+
+  it('should define baseHref if undefined', () => {
+    service['baseHref'] = undefined;
+    service.getConfig();
+    expect(service['baseHref']).toBe('');
+  });
+
+  it('should not redefine baseHref if it is already defined', () => {
+    service['baseHref'] = 'x';
+    service.getConfig();
+    expect(service['baseHref']).not.toBe('');
+  });
 });
diff --git a/projects/grid-failure-information-map-app/src/app/app.component.spec.ts b/projects/grid-failure-information-map-app/src/app/app.component.spec.ts
index d1112f2..2bbb540 100644
--- a/projects/grid-failure-information-map-app/src/app/app.component.spec.ts
+++ b/projects/grid-failure-information-map-app/src/app/app.component.spec.ts
@@ -15,10 +15,14 @@
 
 describe('AppComponent', () => {
   let component: AppComponent;
-  let sandbox : GridFailureSandbox
+  let sandbox: GridFailureSandbox;
 
   beforeEach(() => {
-    component = new AppComponent(null);
+    sandbox = {
+      initSandbox() {},
+      unsubscribe() {},
+    } as any;
+    component = new AppComponent(sandbox);
   });
 
   it('should create the app', () => {
@@ -29,4 +33,15 @@
     expect(component.title).toEqual('grid-failure-information-map-app');
   });
 
+  it('should unsubscribe subscriptions onDestroy', () => {
+    const spy: any = spyOn(sandbox, 'unsubscribe');
+    component.ngOnDestroy();
+    expect(spy).toHaveBeenCalled();
+  });
+
+  it('should init sandbox onInit', () => {
+    const spy: any = spyOn(sandbox, 'initSandbox');
+    component.ngOnInit();
+    expect(spy).toHaveBeenCalled();
+  });
 });
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
index bd6dc0d..004e3db 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.spec.ts
@@ -1,23 +1,48 @@
 /********************************************************************************
-* Copyright (c) 2020 Contributors to the Eclipse Foundation
-*
-* See the NOTICE file(s) distributed with this work for additional
-* information regarding copyright ownership.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v. 2.0 which is available at
-* http://www.eclipse.org/legal/epl-2.0.
-*
-* SPDX-License-Identifier: EPL-2.0
-********************************************************************************/
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
 import { GridFailureSandbox } from '@grid-failure-information-map-app/app/grid-failure/grid-failure.sandbox';
+import { GridFailureService } from '@grid-failure-information-map-app/app/grid-failure/grid-failure.service';
+import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
+import { of } from 'rxjs';
 
 describe('GridFailureSandbox', () => {
   let sandbox: GridFailureSandbox;
-  beforeEach(()=>{
-    sandbox = new GridFailureSandbox(null,null);
+  let gridFailureService: GridFailureService;
+  let configService: AppConfigService;
+
+  beforeEach(() => {
+    configService = {
+      getConfig: () => of(new Object()),
+    } as any;
+    gridFailureService = {
+      getGridFailureData: () => of(new Object()),
+    } as any;
+    sandbox = new GridFailureSandbox(gridFailureService, configService);
   });
+
   it('should create an instance', () => {
     expect(sandbox).toBeTruthy();
   });
+
+  it('should add two subscriptions', () => {
+    const spy: any = spyOn(sandbox['_subscription'], 'add');
+    sandbox.initSandbox();
+    expect(spy).toHaveBeenCalledTimes(2);
+  });
+
+  it('should unsubscribe subscriptions', () => {
+    const spy: any = spyOn(sandbox['_subscription'], 'unsubscribe');
+    sandbox.unsubscribe();
+    expect(spy).toHaveBeenCalled();
+  });
 });
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
index ea0df16..d513c92 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.sandbox.ts
@@ -14,14 +14,13 @@
 import { GridFailureService } from '@grid-failure-information-map-app/app/grid-failure/grid-failure.service';
 import { Subscription } from 'rxjs';
 import { MapOptions } from '@openk-libs/grid-failure-information-map/shared/models/map-options.model';
-import { AppConfigService } from '../app-config.service';
+import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
 import { take } from 'rxjs/operators';
 
 @Injectable()
 export class GridFailureSandbox {
   public gridFailureMapList: any[] = [];
   public mapOptions: MapOptions = new MapOptions();
-  private _mapOptions$: any;
 
   private _subscription: Subscription = new Subscription();
 
@@ -33,13 +32,11 @@
         .getConfig()
         .pipe(take(1))
         .subscribe((data: MapOptions) => {
-          // console.log(`mappOptions ${data}`);
           this.mapOptions = new MapOptions(data);
         })
     );
     this._subscription.add(
       this._gridFailureService.getGridFailureData().subscribe((data: any[]) => {
-        // console.log(`data: ${data}`);
         this.gridFailureMapList = data;
       })
     );
diff --git a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.spec.ts b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.spec.ts
index b4d73b6..e4a6172 100644
--- a/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.spec.ts
+++ b/projects/grid-failure-information-map-app/src/app/grid-failure/grid-failure.service.spec.ts
@@ -17,10 +17,17 @@
   let mockHttpClient: any = null;
 
   beforeEach(() => {
+    mockHttpClient = { get: () => {} };
     service = new GridFailureService(mockHttpClient);
   });
 
   it('should be created', () => {
     expect(service).toBeTruthy();
   });
+
+  it('should get data via getGridFailureData()', () => {
+    const spy: any = spyOn(service['_http'], 'get');
+    service.getGridFailureData();
+    expect(spy).toHaveBeenCalled();
+  });
 });
diff --git a/projects/grid-failure-information-table-app/src/app/app.component.spec.ts b/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
index 427e3ab..b368a5e 100644
--- a/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
+++ b/projects/grid-failure-information-table-app/src/app/app.component.spec.ts
@@ -31,4 +31,13 @@
     component.ngOnInit();
     expect(spy).toHaveBeenCalled();
   });
+
+  it('should set initial sorting', () => {
+    let sortModel;
+    let params = { api: { setSortModel: sortModel = {} } };
+    component['_gridApi'] = params.api;
+    const spy: any = spyOn(component['_gridApi'], 'setSortModel');
+    component.onGridReady(params);
+    expect(spy).toHaveBeenCalled();
+  });
 });
diff --git a/projects/grid-failure-information-table-app/src/app/app.component.ts b/projects/grid-failure-information-table-app/src/app/app.component.ts
index ad17ad2..b70d7aa 100644
--- a/projects/grid-failure-information-table-app/src/app/app.component.ts
+++ b/projects/grid-failure-information-table-app/src/app/app.component.ts
@@ -30,7 +30,6 @@
   public gridOptions: GridOptions;
   public noRowsTemplate: string;
   private _gridApi;
-  private _gridColumnApi;
 
   constructor(private _appTableService: AppTableService) {
     this.defaultColDef = {
@@ -49,7 +48,6 @@
 
   onGridReady(params): void {
     this._gridApi = params.api;
-    this._gridColumnApi = params.columnApi;
     const sortModel = [{ colId: 'failureBegin', sort: 'desc' }];
     this._gridApi.setSortModel(sortModel);
   }