Skip to content

Commit e00dc8b

Browse files
authored
Merge pull request #185 from 0x41head/master
Implemented more tests
2 parents c3d34f1 + 1117d5c commit e00dc8b

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

src/app/app.component.spec.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
import { TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { RouterTestingModule } from '@angular/router/testing';
33
import { AppComponent } from './app.component';
44

55
describe('AppComponent', () => {
6+
let app: AppComponent;
7+
let fixture: ComponentFixture<AppComponent>;
8+
69
beforeEach(async () => {
710
await TestBed.configureTestingModule({
811
imports: [RouterTestingModule],
912
declarations: [AppComponent],
1013
}).compileComponents();
1114
});
1215

16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(AppComponent);
18+
app = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
1322
it('should create the app', () => {
14-
const fixture = TestBed.createComponent(AppComponent);
15-
const app = fixture.componentInstance;
1623
expect(app).toBeTruthy();
1724
});
1825

1926
it(`should have as title 'DSOMM'`, () => {
20-
const fixture = TestBed.createComponent(AppComponent);
21-
const app = fixture.componentInstance;
2227
expect(app.title).toEqual('DSOMM');
2328
});
29+
30+
it('check for fork me on github ribbon generation', () => {
31+
const fixture = TestBed.createComponent(AppComponent);
32+
const HTMLElement: HTMLElement = fixture.nativeElement;
33+
var divTag = HTMLElement.querySelector('div')!;
34+
var aTag = divTag.querySelector('a')!;
35+
//console.log(aTag);
36+
expect(aTag.textContent).toEqual('Fork me on GitHub');
37+
});
2438
});

src/app/component/mapping/mapping.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,18 @@ describe('MappingComponent', () => {
2525
it('should create', () => {
2626
expect(component).toBeTruthy();
2727
});
28+
29+
it('check for table generation', () => {
30+
const HTMLElement: HTMLElement = fixture.nativeElement;
31+
const table = HTMLElement.querySelector('table')!;
32+
expect(table).toBeTruthy();
33+
});
34+
35+
it('check for chip deletion', () => {
36+
component.currentChip = ['row1', 'row2'];
37+
component.removeChip('row1');
38+
const newChipRow = ['row2'];
39+
fixture.detectChanges();
40+
expect(component.currentChip).toEqual(newChipRow);
41+
});
2842
});

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ describe('MatrixComponent', () => {
3434
const table = HTMLElement.querySelector('table')!;
3535
expect(table).toBeTruthy();
3636
});
37+
38+
it('check for chip deletion', () => {
39+
component.rowsCurrentlyBeingShown = ['row1', 'row2'];
40+
component.remove('row1');
41+
const newChipRow = ['row2'];
42+
fixture.detectChanges();
43+
expect(component.rowsCurrentlyBeingShown).toEqual(newChipRow);
44+
});
3745
});

0 commit comments

Comments
 (0)