Skip to content

Commit 6d92a2d

Browse files
committed
Initial commit for more tests
1 parent c888a69 commit 6d92a2d

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/app/component/matrix/matrix.component.spec.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HttpClient, HttpHandler } from '@angular/common/http';
1+
import { HttpClientModule, HttpHandler } from '@angular/common/http';
22
import { HttpClientTestingModule } from '@angular/common/http/testing';
33
import { ComponentFixture, TestBed } from '@angular/core/testing';
44
import { MatAutocomplete } from '@angular/material/autocomplete';
@@ -12,19 +12,35 @@ describe('MatrixComponent', () => {
1212

1313
beforeEach(async () => {
1414
await TestBed.configureTestingModule({
15-
providers: [ymlService, HttpClient, HttpHandler, HttpClientTestingModule],
16-
imports: [RouterTestingModule],
15+
providers: [ymlService, HttpClientTestingModule],
16+
imports: [RouterTestingModule, HttpClientModule],
1717
declarations: [MatrixComponent, MatAutocomplete],
1818
}).compileComponents();
1919
});
2020

2121
beforeEach(() => {
2222
fixture = TestBed.createComponent(MatrixComponent);
2323
component = fixture.componentInstance;
24+
component.ngOnInit();
2425
fixture.detectChanges();
2526
});
2627

2728
it('should create', () => {
29+
fixture.detectChanges();
2830
expect(component).toBeTruthy();
2931
});
32+
33+
it('check for table generation', () => {
34+
const HTMLElement: HTMLElement = fixture.nativeElement;
35+
const table = HTMLElement.querySelector('table')!;
36+
expect(table).toBeTruthy();
37+
//expect(p.textContent).toEqual('banner works!');
38+
});
39+
40+
it('check if all rows are being shown as chips', () => {
41+
var check = JSON.parse(JSON.stringify(component.MATRIX_DATA));
42+
console.log(check);
43+
expect(component.rowsCurrentlyBeingShown).toEqual(component.allRows);
44+
//expect(p.textContent).toEqual('banner works!');
45+
});
3046
});

src/app/component/matrix/matrix.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ export class MatrixComponent implements OnInit {
9494
this.YamlObject[this.allDimensionNames[i]][
9595
subdimensionsInCurrentDimension[j]
9696
][currentTaskName]['level'];
97-
console.log(
98-
temp[this.lvlColumn[lvlOfTask - 1] as keyof MatrixElement]
99-
);
97+
//console.log(temp[this.lvlColumn[lvlOfTask - 1] as keyof MatrixElement]);
10098
(
10199
temp[
102100
this.lvlColumn[lvlOfTask - 1] as keyof MatrixElement
@@ -109,7 +107,7 @@ export class MatrixComponent implements OnInit {
109107
//console.log(this.YamlObject['dimension'][i]['subdimension'][lvlTemp][k]['name'])
110108
}
111109

112-
console.log(temp);
110+
//console.log(temp);
113111
this.MATRIX_DATA.push(temp);
114112
}
115113
}
@@ -189,8 +187,8 @@ export class MatrixComponent implements OnInit {
189187
taskName: taskName,
190188
},
191189
};
192-
console.log(this.lvlColumn);
193-
console.log(this.levels);
190+
//console.log(this.lvlColumn);
191+
//console.log(this.levels);
194192
this.router.navigate([this.Routing], navigationExtras);
195193
}
196194
}

0 commit comments

Comments
 (0)