[SI-1870] 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-details/grid-failure-details.component.spec.ts b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
index 2e3fa31..d3fcb90 100644
--- a/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
+++ b/projects/grid-failure-information-app/src/app/pages/grid-failure/grid-failure-details/grid-failure-details.component.spec.ts
@@ -1,3 +1,4 @@
+import { FailureBranch } from './../../../shared/models/failure-branch.model';
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
@@ -50,6 +51,7 @@
setSelectedStation() {},
resetFailureLocationValues() {},
deleteGridFailureStation() {},
+ setBranchState() {},
gridFailureDetailsFormState$: of({ ...INITIAL_STATE, gridFailureDetailsFormResponse } as any),
currentFormState: INITIAL_STATE,
disableStationAttributes: false,
@@ -282,16 +284,42 @@
expect(spy).toHaveBeenCalled();
});
- it('should change to currentVersionMode in response to disableStationAttributes=false', () => {
+ it('should change to currentVersionMode in response to oldVersion=false', () => {
const spy = spyOn(component.events$, 'next');
component.changeMode();
expect(spy).toHaveBeenCalledWith({ eventType: component['_modeEnum'].currentVersionMode });
});
+ it('should change to currentVersionMode in response to oldVersion=true', () => {
+ const spy = spyOn(component.events$, 'next');
+ component.gridFailureDetailsSandbox.oldVersion = true;
+ component.changeMode();
+ expect(spy).toHaveBeenCalledWith({ eventType: component['_modeEnum'].oldVersionMode });
+ });
+
+ it('should call deleteGridFailureStation function for delete event', () => {
+ const spy: any = spyOn(gridFailureSandbox, 'deleteGridFailureStation');
+ component.ngOnInit();
+ component.gridOptions.context.eventSubject.next({ type: 'delete', data: new models.FailureStation() });
+ expect(spy).toHaveBeenCalled();
+ });
+
it('should not call deleteGridFailureStation function for other (not delete) event', () => {
const spy: any = spyOn(gridFailureSandbox, 'deleteGridFailureStation');
component.ngOnInit();
component.gridOptions.context.eventSubject.next({ type: 'test', data: new models.FailureStation() });
expect(spy).not.toHaveBeenCalled();
});
+
+ it('should set Branch State correctly', () => {
+ const spy: any = spyOn(gridFailureSandbox, 'setBranchState');
+ component.gridFailureDetailsSandbox.branches = [new FailureBranch()];
+ component.setBrancheValue('id1');
+ expect(spy).toHaveBeenCalled();
+ });
+
+ it('should set gridOptions context icons', () => {
+ component.setNewGridOptions('1');
+ expect(component.gridOptions.context.icons).toBeDefined();
+ });
});