[KON-128] unit tests + mods code review
Signed-off-by: Peter Buschmann <peter.buschmann@pta.de>
diff --git a/i18n/contacts.de.json b/i18n/contacts.de.json
index e7a561a..4229d41 100644
--- a/i18n/contacts.de.json
+++ b/i18n/contacts.de.json
@@ -9,9 +9,5 @@
"InternContact": "Interner Kontakt",
"ExternContact": "Externer Kontakt",
"Company": "Unternehmen"
- },
- "ContactDetails": {
- "Title": "Details",
- "MandatoryFieldsNotFilled": "Es ist mindestens ein Pflichtfeld nicht gefüllt."
}
}
diff --git a/sonar-project.properties b/sonar-project.properties
index 39a7d49..8576441 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -9,9 +9,9 @@
sonar.sourceEncoding=UTF-8
sonar.sources=src
-sonar.exclusions=**/node_modules/**,**/*.spec.ts,**/test-data/*.ts,**/testing/*.ts,**/assets/js/*.js,**/*.model.*,**/*.action.*,**/*column-definition*,**/*.module.*,**/*column-definition*,**/*api-client.service.*,**/styles.scss
+sonar.exclusions=**/node_modules/**,**/*.spec.ts,**/test-data/*.ts,**/testing/*.ts,**/assets/js/*.js,**/*.model.*,**/*.action.*,**/*column-definition*,**/*.module.*,**/*column-definition*,**/*api-client.*,**/styles.scss
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
-sonar.test.exclusions=**/multiselect-dropdown/*.ts
+sonar.test.exclusions=
sonar.ts.tslintconfigpath=tslint.json
sonar.typescript.lcov.reportPaths=coverage/lcov.info
diff --git a/src/app/pages/admin/salutations/salutations-api-client.ts b/src/app/pages/admin/salutations/salutations-api-client.ts
index 293bcea..08d6d73 100644
--- a/src/app/pages/admin/salutations/salutations-api-client.ts
+++ b/src/app/pages/admin/salutations/salutations-api-client.ts
@@ -6,7 +6,6 @@
@Injectable()
@DefaultHeaders({
- // prettier-ignore
'Accept': 'application/json',
'Content-Type': 'application/json',
})
diff --git a/src/app/pages/admin/salutations/salutations-details/salutations-details.component.spec.ts b/src/app/pages/admin/salutations/salutations-details/salutations-details.component.spec.ts
index 7b02501..056906b 100644
--- a/src/app/pages/admin/salutations/salutations-details/salutations-details.component.spec.ts
+++ b/src/app/pages/admin/salutations/salutations-details/salutations-details.component.spec.ts
@@ -1,4 +1,4 @@
-import { SalutationsDetailsComponent } from './salutations-details.component';
+import { SalutationsDetailsComponent } from '@app/pages/admin/salutations/salutations-details/salutations-details.component';
describe('SalutationsDetailsComponent', () => {
let component: SalutationsDetailsComponent;
diff --git a/src/app/pages/admin/salutations/salutations-details/salutations-details.component.ts b/src/app/pages/admin/salutations/salutations-details/salutations-details.component.ts
index 04439e9..2e2420d 100644
--- a/src/app/pages/admin/salutations/salutations-details/salutations-details.component.ts
+++ b/src/app/pages/admin/salutations/salutations-details/salutations-details.component.ts
@@ -1,4 +1,4 @@
-import { SalutationsSandbox } from '@app/pages/admin//salutations/salutations.sandbox';
+import { SalutationsSandbox } from '@app/pages/admin/salutations/salutations.sandbox';
import { Component } from '@angular/core';
@Component({
diff --git a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.html b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.html
index c71a8fd..042bf72 100644
--- a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.html
+++ b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.html
@@ -10,7 +10,7 @@
<div class="salutations-grid-wrapper" body>
<ag-grid-angular
autoresizecolumns
- class="ag-theme-balham"
+ class="ag-theme-balham ag-grid-height"
[gridOptions]="gridOptions"
[columnDefs]="columnDefinition"
[rowSelection]="'single'"
diff --git a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.scss b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.scss
index e71fac3..bee1b1d 100644
--- a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.scss
+++ b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.scss
@@ -6,7 +6,7 @@
margin-top: 20px;
}
-ag-grid-angular {
+.ag-grid-height {
height: calc(100vh - 450px);
}
diff --git a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.spec.ts b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.spec.ts
index d5dd873..4701dd6 100644
--- a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.spec.ts
+++ b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.spec.ts
@@ -1,10 +1,8 @@
import { Salutation } from '@shared/models';
-import { async } from '@angular/core/testing';
-import { SalutationsListComponent } from './salutations-list.component';
+import { SalutationsListComponent } from '@pages/admin/salutations/salutations-list//salutations-list.component';
describe('SalutationsListComponent', () => {
let component: SalutationsListComponent;
- // let sandbox: SalutationsSandbox;
const sandbox: any = {
setDisplayForm: () => {},
loadSalutation: () => {},
diff --git a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.ts b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.ts
index 8703dd7..394ccc7 100644
--- a/src/app/pages/admin/salutations/salutations-list/salutations-list.component.ts
+++ b/src/app/pages/admin/salutations/salutations-list/salutations-list.component.ts
@@ -30,10 +30,10 @@
if (event.type === 'edit') {
this.salutationsSandbox.setDisplayForm();
this.salutationsSandbox.loadSalutation(event.data.id);
- };
+ }
if (event.type === 'delete') {
this.salutationsSandbox.deleteSalutation(event.data.id);
- };
+ }
});
}
diff --git a/src/app/pages/admin/salutations/salutations.service.spec.ts b/src/app/pages/admin/salutations/salutations.service.spec.ts
index 554b4fb..cc596bc 100644
--- a/src/app/pages/admin/salutations/salutations.service.spec.ts
+++ b/src/app/pages/admin/salutations/salutations.service.spec.ts
@@ -1,5 +1,5 @@
import { Salutation } from '@shared/models';
-import { SalutationsService } from './salutations.service';
+import { SalutationsService } from '@pages/admin/salutations/salutations.service';
describe('SalutationsService', () => {
let service: SalutationsService;
diff --git a/src/app/pages/contacts/contacts-list/contacts-list.component.html b/src/app/pages/contacts/contacts-list/contacts-list.component.html
index 01991e7..5204fa9 100644
--- a/src/app/pages/contacts/contacts-list/contacts-list.component.html
+++ b/src/app/pages/contacts/contacts-list/contacts-list.component.html
@@ -17,7 +17,7 @@
<ag-grid-angular
[serverside]="contactsSandbox.serversideModel"
autoresizecolumns
- class="ag-theme-balham"
+ class="ag-theme-balham ag-grid-height"
[gridOptions]="gridOptions"
[columnDefs]="columnDefinition"
[rowSelection]="'single'"
diff --git a/src/app/pages/contacts/contacts-list/contacts-list.component.scss b/src/app/pages/contacts/contacts-list/contacts-list.component.scss
index b20227a..1ab7fc7 100644
--- a/src/app/pages/contacts/contacts-list/contacts-list.component.scss
+++ b/src/app/pages/contacts/contacts-list/contacts-list.component.scss
@@ -15,8 +15,7 @@
margin-bottom: 1px;
}
-
-ag-grid-angular{
+.ag-grid-height{
height: calc(100vh - 275px);
}
diff --git a/src/app/pages/contacts/contacts.service.ts b/src/app/pages/contacts/contacts.service.ts
index 64c0777..70ae06b 100644
--- a/src/app/pages/contacts/contacts.service.ts
+++ b/src/app/pages/contacts/contacts.service.ts
@@ -1,4 +1,4 @@
-import { PageModel } from './../../shared/models/page/page.model';
+import { PageModel } from '@shared/models/page/page.model';
import { Injectable } from '@angular/core';
import { Contact } from '@shared/models';
diff --git a/src/app/shared/components/dialogs/safety-query-dialog/safety-query-dialog.component.spec.ts b/src/app/shared/components/dialogs/safety-query-dialog/safety-query-dialog.component.spec.ts
index 2ca45ed..7c660b1 100644
--- a/src/app/shared/components/dialogs/safety-query-dialog/safety-query-dialog.component.spec.ts
+++ b/src/app/shared/components/dialogs/safety-query-dialog/safety-query-dialog.component.spec.ts
@@ -1,4 +1,4 @@
-import { SafetyQueryDialogComponent } from './safety-query-dialog.component';
+import { SafetyQueryDialogComponent } from '@shared/components/dialogs/safety-query-dialog/safety-query-dialog.component';
describe('SafetyQueryDialogComponent', () => {
let component: SafetyQueryDialogComponent;
diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts
index 9728b85..b21bd0c 100644
--- a/src/app/shared/components/index.ts
+++ b/src/app/shared/components/index.ts
@@ -2,7 +2,7 @@
import { IconCellRendererComponent } from '@shared/components/cell-renderer/icon-cell-renderer/icon-cell-renderer.component';
import { ContactTypeCellRendererComponent } from '@shared/components/cell-renderer/contact-type-cell-renderer/contact-type-cell-renderer.component';
import { PaginatorComponent } from '@shared/components/paginator/paginator.component';
-import { LoadingSpinnerComponent } from './loading-spinner/loading-spinner.component';
+import { LoadingSpinnerComponent } from '@shared/components/loading-spinner/loading-spinner.component';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
@@ -13,7 +13,7 @@
import { HeaderComponent } from '@shared/components/header/header.component';
import { LanguageSelectorComponent } from '@shared/components/languageSelector/languageSelector.component';
import { PageNotFoundComponent } from '@shared/components/pageNotFound/pageNotFound.component';
-import { LoadingPlaceholderComponent } from './loadingPlaceholder/loadingPlaceholder.component';
+import { LoadingPlaceholderComponent } from '@shared/components/loadingPlaceholder/loadingPlaceholder.component';
import { VersionInfo } from '@shared/components/version-info/version-info.component';
import { AngularFontAwesomeModule } from 'angular-font-awesome';
diff --git a/src/app/shared/containers/card-layout/card-layout.component.scss b/src/app/shared/containers/card-layout/card-layout.component.scss
index b25f222..b86df3f 100644
--- a/src/app/shared/containers/card-layout/card-layout.component.scss
+++ b/src/app/shared/containers/card-layout/card-layout.component.scss
@@ -1,7 +1,7 @@
.card {
height: calc(100vh - 145px);
overflow: auto;
- border: none;;
+ border: none;
}
.card-title {
font-size: 30px;
diff --git a/src/app/shared/store/effects/contacts.effect.ts b/src/app/shared/store/effects/contacts.effect.ts
index 155b1b0..13c7375 100644
--- a/src/app/shared/store/effects/contacts.effect.ts
+++ b/src/app/shared/store/effects/contacts.effect.ts
@@ -9,20 +9,6 @@
import { catchError, map, switchMap } from 'rxjs/operators';
import { PageRequestInterface } from '@shared/models/page/page-request.interface';
-/**
- * Effects offer a way to isolate and easily test side-effects within your
- * application. StateUpdates is an observable of the latest state and
- * dispatched action. The `toPayload` helper function returns just
- * the payload of the currently dispatched action, useful in
- * instances where the current state is not necessary.
- *
- * If you are unfamiliar with the operators being used in these examples, please
- * check out the sources below:
- *
- * Official Docs: http://reactivex.io/rxjs/manual/overview.html#categories-of-operators
- * RxJS 5 Operators By Example: https://gist.github.com/btroncone/d6cf141d6f2c00dc6b35
- */
-
@Injectable()
export class ContactsEffects {
/* plain list */
diff --git a/src/app/shared/store/effects/contacts.effects.spec.ts b/src/app/shared/store/effects/contacts.effects.spec.ts
index 287e856..fb0d1c3 100644
--- a/src/app/shared/store/effects/contacts.effects.spec.ts
+++ b/src/app/shared/store/effects/contacts.effects.spec.ts
@@ -1,4 +1,4 @@
-import { PageRequestInterface } from './../../models/page/page-request.interface';
+import { PageRequestInterface } from '@shared/models/page/page-request.interface';
import { take } from 'rxjs/operators';
import { ContactsEffects } from '@shared/store/effects/contacts.effect';
import { Subject, of, throwError } from 'rxjs';
diff --git a/src/app/shared/store/effects/salutations.effect.ts b/src/app/shared/store/effects/salutations.effect.ts
index 6821847..a30b1ce 100644
--- a/src/app/shared/store/effects/salutations.effect.ts
+++ b/src/app/shared/store/effects/salutations.effect.ts
@@ -10,20 +10,6 @@
import { Salutation } from '@app/shared/models';
import { Store } from '@ngrx/store';
-/**
- * Effects offer a way to isolate and easily test side-effects within your
- * application. StateUpdates is an observable of the latest state and
- * dispatched action. The `toPayload` helper function returns just
- * the payload of the currently dispatched action, useful in
- * instances where the current state is not necessary.
- *
- * If you are unfamiliar with the operators being used in these examples, please
- * check out the sources below:
- *
- * Official Docs: http://reactivex.io/rxjs/manual/overview.html#categories-of-operators
- * RxJS 5 Operators By Example: https://gist.github.com/btroncone/d6cf141d6f2c00dc6b35
- */
-
@Injectable()
export class SalutationsEffects {
/**
diff --git a/src/app/shared/store/effects/salutations.effects.spec.ts b/src/app/shared/store/effects/salutations.effects.spec.ts
index 33e5677..ce5c84b 100644
--- a/src/app/shared/store/effects/salutations.effects.spec.ts
+++ b/src/app/shared/store/effects/salutations.effects.spec.ts
@@ -1,10 +1,9 @@
-import { take } from 'rxjs/operators';
import { Subject, of, Subscription } from 'rxjs';
import { Action } from '@ngrx/store';
import { TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Actions } from '@ngrx/effects';
-import { SalutationsEffects } from './salutations.effect';
+import { SalutationsEffects } from '@shared/store/effects/salutations.effect';
class MockStore{}
diff --git a/src/app/shared/store/index.ts b/src/app/shared/store/index.ts
index 1201ba3..dddd500 100644
--- a/src/app/shared/store/index.ts
+++ b/src/app/shared/store/index.ts
@@ -1,4 +1,4 @@
-import { Salutation } from './../models/salutation.model';
+import { Salutation } from '@shared/models/salutation.model';
import { createSelector } from 'reselect';
/**
* Every reducer module's default export is the reducer function itself. In
diff --git a/src/app/shared/store/reducers/contacts/contacts-page.reducer.ts b/src/app/shared/store/reducers/contacts/contacts-page.reducer.ts
index 9d0e3f7..633d6d6 100644
--- a/src/app/shared/store/reducers/contacts/contacts-page.reducer.ts
+++ b/src/app/shared/store/reducers/contacts/contacts-page.reducer.ts
@@ -49,9 +49,6 @@
})
);
export function reducer(state = INITIAL_STATE, action: Action): State {
- // if (!action) {
- // return state;
- // }
return contactsPageReducer(state, action);
}
diff --git a/src/app/shared/store/reducers/salutations/salutations-details-form.reducer.spec.ts b/src/app/shared/store/reducers/salutations/salutations-details-form.reducer.spec.ts
new file mode 100644
index 0000000..a90b9b1
--- /dev/null
+++ b/src/app/shared/store/reducers/salutations/salutations-details-form.reducer.spec.ts
@@ -0,0 +1,37 @@
+import * as fromReducer from '@shared/store/reducers/salutations/salutations-details-form.reducer';
+import { Salutation } from '@shared/models';
+import { Action } from '@ngrx/store';
+import { FormGroupState } from 'ngrx-forms';
+
+
+describe('Salutation Detail Form reducer', () => {
+ const { INITIAL_STATE } = fromReducer;
+
+ it('should return the default state when no state is given', () => {
+ const action: Action = { type: 'testAction' };
+ const state: FormGroupState<Salutation> = fromReducer.reducer(undefined, action);
+
+ expect(state).toBe(INITIAL_STATE);
+ });
+
+ it('should return the initial state when action is not found', () => {
+ const action: Action = { type: 'testAction' };
+ const state: FormGroupState<Salutation> = fromReducer.reducer(INITIAL_STATE, action);
+
+ expect(state).toBe(INITIAL_STATE);
+ });
+
+ it('should return the initial state when no action set', () => {
+ const action: Action = null;
+ const state: FormGroupState<Salutation> = fromReducer.reducer(INITIAL_STATE, action);
+
+ expect(state).toBe(INITIAL_STATE);
+ });
+
+ it('should return state via getFormState', () => {
+ const action: Action = null;
+ const state: FormGroupState<Salutation> = fromReducer.reducer(INITIAL_STATE, action);
+ expect(fromReducer.getFormState(state)).toBe(state);
+ });
+
+});