Skip to content

Commit 6b5561d

Browse files
authored
Merge pull request #172 from 0x41head/master
More Tests
2 parents c888a69 + df55d9d commit 6b5561d

3 files changed

Lines changed: 39 additions & 9 deletions

File tree

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

Lines changed: 10 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,8 +12,8 @@ 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
});
@@ -25,6 +25,13 @@ describe('MatrixComponent', () => {
2525
});
2626

2727
it('should create', () => {
28+
fixture.detectChanges();
2829
expect(component).toBeTruthy();
2930
});
31+
32+
it('check for table generation', () => {
33+
const HTMLElement: HTMLElement = fixture.nativeElement;
34+
const table = HTMLElement.querySelector('table')!;
35+
expect(table).toBeTruthy();
36+
});
3037
});

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
}

src/app/component/sidenav-buttons/sidenav-buttons.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Component } from '@angular/core';
12
import { ComponentFixture, TestBed } from '@angular/core/testing';
23

34
import { SidenavButtonsComponent } from './sidenav-buttons.component';
@@ -21,4 +22,28 @@ describe('SidenavButtonsComponent', () => {
2122
it('should create', () => {
2223
expect(component).toBeTruthy();
2324
});
25+
26+
it('check for navigation list generation', () => {
27+
const HTMLElement: HTMLElement = fixture.nativeElement;
28+
const NavigationList = HTMLElement.querySelector('mat-nav-list')!;
29+
//console.log(NavigationList);
30+
expect(NavigationList).toBeTruthy();
31+
});
32+
33+
it('check for navigation names being shown in the same order as options array', () => {
34+
const HTMLElement: HTMLElement = fixture.nativeElement;
35+
const NavigationList = HTMLElement.querySelectorAll('h3')!;
36+
let NavigationNamesBeingShown = [];
37+
for (var x = 0; x < NavigationList.length; x += 1) {
38+
NavigationNamesBeingShown.push(NavigationList[x].textContent);
39+
}
40+
//console.log({ ...NavigationNamesBeingShown });
41+
//console.log(component.Options);
42+
expect(NavigationNamesBeingShown).toEqual(component.Options);
43+
});
44+
45+
it('ensure all navigation options has its own icon and route', () => {
46+
expect(component.Icons.length).toEqual(component.Options.length);
47+
expect(component.Routing.length).toEqual(component.Options.length);
48+
});
2449
});

0 commit comments

Comments
 (0)