Moved testing ts after merge

This commit is contained in:
Nicolai Ort 2020-07-14 18:37:34 +02:00
parent da4c74b46a
commit 62e1a5fc9a
2 changed files with 120 additions and 121 deletions

View File

@ -1,28 +1,28 @@
import { TestBed, async } from '@angular/core/testing'; import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { BackendService } from '../../services/backend.service'; import { BackendService } from '../../../services/backend.service';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { SprintTableComponent } from './sprint-table.component'; import { SprintTableComponent } from './sprint-table.component';
describe('SprintTableComponent', () => { describe('SprintTableComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
RouterTestingModule, RouterTestingModule,
HttpClientModule, HttpClientModule,
], ],
declarations: [ declarations: [
SprintTableComponent, SprintTableComponent,
], ],
providers: [ providers: [
BackendService, BackendService,
] ]
}).compileComponents(); }).compileComponents();
})); }));
it('should create the component', () => { it('should create the component', () => {
const fixture = TestBed.createComponent(SprintTableComponent); const fixture = TestBed.createComponent(SprintTableComponent);
const app = fixture.debugElement.componentInstance; const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy(); expect(app).toBeTruthy();
}); });
}); });

View File

@ -1,93 +1,92 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { BackendService, ScrumSprint } from '../../../services/backend.service'; import { BackendService, ScrumSprint } from '../../../services/backend.service';
import { TableComponentBase } from '../table-component.base'; import { TableComponentBase } from '../table-component.base';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { SprintFormComponent } from '../../sprint-form/sprint-form.component'; import { SprintFormComponent } from '../../sprint-form/sprint-form.component';
@Component({ @Component({
selector: 'app-sprint', selector: 'app-sprint',
templateUrl: './sprint-table.component.html', templateUrl: './sprint-table.component.html',
styleUrls: ['./sprint-table.component.css'], styleUrls: ['./sprint-table.component.css'],
}) })
export class SprintTableComponent extends TableComponentBase<ScrumSprint> { export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
/** /**
* Constructor that establishes the initial backend communication. * Constructor that establishes the initial backend communication.
* @param backendService backendService object for backend communication * @param backendService backendService object for backend communication
* @param modalService angular modalService to handle modals for the Form popups * @param modalService angular modalService to handle modals for the Form popups
* @param route route object to extract parameters from * @param route route object to extract parameters from
*/ */
constructor( constructor(
private backendService: BackendService, private backendService: BackendService,
private modalService: NgbModal, private modalService: NgbModal,
protected route: ActivatedRoute protected route: ActivatedRoute
) { ) {
super(route); super(route);
backendService.getSprints().subscribe((response) => { backendService.getSprints().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
this.items.push(...response.body); this.items.push(...response.body);
} }
}); });
} }
//#region getters //#region getters
//#endregion getters //#endregion getters
//#region sprintTableFunctions //#region sprintTableFunctions
/** /**
* Deletes a sprint by calling the delete method via the backendService and removing it from the tabel's items array. * Deletes a sprint by calling the delete method via the backendService and removing it from the tabel's items array.
* @param sprint sprint that will be deleted * @param sprint sprint that will be deleted
*/ */
public deleteSprint(sprint: ScrumSprint) { public deleteSprint(sprint: ScrumSprint) {
this.backendService.deleteSprint(sprint).subscribe((response) => { this.backendService.deleteSprint(sprint).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} }
}); });
const index = this.items.indexOf(sprint); const index = this.items.indexOf(sprint);
if (index !== -1) { if (index !== -1) {
this.items.splice(index, 1); this.items.splice(index, 1);
} }
} }
//#endregion sprintTableFunctions //#endregion sprintTableFunctions
//#region sorters //#region sorters
/** /**
* Sorts the tabel's items by startDate * Sorts the tabel's items by startDate
*/ */
sortByStartDate() { sortByStartDate() {
this.doStringSort('startDate', (sprint) => sprint.startDate); this.doStringSort('startDate', (sprint) => sprint.startDate);
} }
/** /**
* Sorts the tabel's items by endDate * Sorts the tabel's items by endDate
*/ */
sortByEndDate() { sortByEndDate() {
this.doStringSort('endDate', (sprint) => sprint.endDate); this.doStringSort('endDate', (sprint) => sprint.endDate);
} }
//#endregion sorters //#endregion sorters
//#region modals //#region modals
/** /**
* Opens a SprintForm popup for editing a existing sprint or creating a new one. * Opens a SprintForm popup for editing a existing sprint or creating a new one.
* @param editSprint optional: sprint to edit (only needed if a task should be edited, not newly created) * @param editSprint optional: sprint to edit (only needed if a task should be edited, not newly created)
*/ */
public openSprintForm(editSprint?: ScrumSprint) { public openSprintForm(editSprint?: ScrumSprint) {
const modalRef = this.modalService.open(SprintFormComponent, { const modalRef = this.modalService.open(SprintFormComponent, {
backdrop: 'static', backdrop: 'static',
keyboard: true, keyboard: true,
size: 'md', size: 'md',
}); });
if (editSprint == null) { if (editSprint == null) {
modalRef.result.then((result) => { modalRef.result.then((result) => {
alert("hi"); this.items.push(result);
this.items.push(result); });
}); }
} modalRef.componentInstance.sprint = editSprint;
modalRef.componentInstance.sprint = editSprint; }
} //#endregion modals
//#endregion modals }
}