[SI-92] unit tests added
Signed-off-by: Peter Buschmann <peter.buschmann@pta.de>
diff --git a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
index a87b89d..5da79e0 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-list/grid-failure-list.component.spec.ts
@@ -91,12 +91,18 @@
expect(component.condensationColumnDefinition).not.toBeDefined();
});
- it('should pass external filter if the appropriate conditions are met', () => {
+ it('should pass external filter if the appropriate conditions are met (published)', () => {
let node: any = { data: { publicationStatus: StateEnum.PUBLISHED } };
component.sandbox.publisherFilterIsActive = true;
expect(component.doesExternalFilterPass(node)).toBeTruthy();
});
+ it('should pass external filter if the appropriate conditions are met (qualified)', () => {
+ let node: any = { data: { statusIntern: StateEnum.QUALIFIED } };
+ component.sandbox.publisherFilterIsActive = true;
+ expect(component.doesExternalFilterPass(node)).toBeTruthy();
+ });
+
it('should should not pass external filter if the appropriate conditions are not met', () => {
let node: any;
expect(component.doesExternalFilterPass(node)).toBeFalsy();
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 defb76b..6434262 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
@@ -24,4 +24,10 @@
it('should be created', () => {
expect(service).toBeTruthy();
});
+
+ it('should call http het via getConfig()', () => {
+ const spy: any = spyOn(service['http'], 'get');
+ service.getConfig();
+ expect(spy).toHaveBeenCalledWith('public-settings');
+ });
});
diff --git a/projects/grid-failure-information-table-app/src/app/app-config.service.spec.ts b/projects/grid-failure-information-table-app/src/app/app-config.service.spec.ts
index defb76b..f7f1837 100644
--- a/projects/grid-failure-information-table-app/src/app/app-config.service.spec.ts
+++ b/projects/grid-failure-information-table-app/src/app/app-config.service.spec.ts
@@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
-import { AppConfigService } from '@grid-failure-information-map-app/app/app-config.service';
+import { AppConfigService } from '@grid-failure-information-table-app/app/app-config.service';
describe('AppConfigService', () => {
let service: AppConfigService;
@@ -24,4 +24,10 @@
it('should be created', () => {
expect(service).toBeTruthy();
});
+
+ it('should call http het via getConfig()', () => {
+ const spy: any = spyOn(service['http'], 'get');
+ service.getConfig();
+ expect(spy).toHaveBeenCalledWith('public-settings');
+ });
});
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 c0c0e99..0e760be 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
@@ -12,20 +12,25 @@
********************************************************************************/
import { TableComponent } from '@grid-failure-information-table-app/app/app.component';
import { AppTableService } from '@grid-failure-information-table-app/app/app-table.service';
-import { GridFailure } from '@grid-failure-information-app/shared/models';
+import { AppConfigService } from '@grid-failure-information-table-app/app/app-config.service';
+import { GridFailure, Settings } from '@grid-failure-information-app/shared/models';
import { of } from 'rxjs';
describe('AppComponent', () => {
let component: TableComponent;
let service: AppTableService;
+ let configService: AppConfigService;
let gridFailureMapListAll: GridFailure[] = [];
beforeEach(() => {
service = {
- loadGridFailureData: () => of(true)
+ loadGridFailureData: () => of(true),
+ } as any;
+ configService = {
+ getConfig: () => of(true),
} as any;
gridFailureMapListAll = [new GridFailure({ postcode: '007' }), new GridFailure({ postcode: '4711' }), new GridFailure({ postcode: '0815' })];
- component = new TableComponent(service);
+ component = new TableComponent(service, configService);
(component as any)._gridFailuresAll = gridFailureMapListAll;
component.gridFailures = gridFailureMapListAll.map(i => Object.assign(i));
});
@@ -59,4 +64,15 @@
expect(component.gridFailures.length).toEqual(1);
expect(component.gridFailures[0].postcode).toEqual('007');
});
+
+ it('should xxx', () => {
+ let config = new Settings();
+ config.visibilityConfiguration = { tableExternColumnVisibility: { failureClassification: 'show' } } as any;
+ configService = {
+ getConfig: () => of(config),
+ } as any;
+ component = new TableComponent(service, configService);
+ component.ngOnInit();
+ expect(component.columnDefs).toBeDefined();
+ });
});
diff --git a/projects/grid-failure-information-table-app/src/app/utilityHelpers.spec.ts b/projects/grid-failure-information-table-app/src/app/utilityHelpers.spec.ts
index b28aa07..6922310 100644
--- a/projects/grid-failure-information-table-app/src/app/utilityHelpers.spec.ts
+++ b/projects/grid-failure-information-table-app/src/app/utilityHelpers.spec.ts
@@ -42,4 +42,14 @@
let testValue = utilityHelpers.dateTimeComparator(filterLocalDateAtMidnight, null);
expect(testValue).toBe(-1);
});
+
+ it('should compare two strings via stringInsensitiveComparator', () => {
+ let testValue = utilityHelpers.stringInsensitiveComparator('A', 'b');
+ expect(testValue).toBe(-1);
+ });
+
+ it('should handle null values in stringInsensitiveComparator ', () => {
+ let testValue = utilityHelpers.stringInsensitiveComparator(null, null);
+ expect(testValue).toBe(0);
+ });
});