mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2025-04-19 15:29:18 +00:00
* BETTERZON-83: Making pre-generated unit tests work * BETTERZON-83: Writing unit tests for angular to improve code coverage
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
|
|
import {FooterComponent} from './footer.component';
|
|
import {RouterTestingModule} from "@angular/router/testing";
|
|
import {AppComponent} from "../../app.component";
|
|
import {ImprintComponent} from "../../pages/imprint/imprint.component";
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
|
|
|
describe('FooterComponent', () => {
|
|
let component: FooterComponent;
|
|
let fixture: ComponentFixture<FooterComponent>;
|
|
let router = {
|
|
navigate: jasmine.createSpy('navigate'),
|
|
routerState: jasmine.createSpy('routerState')
|
|
}
|
|
|
|
beforeEach(async () => {
|
|
await TestBed.configureTestingModule({
|
|
providers: [{provide: Router, useValue: router}],
|
|
declarations: [FooterComponent],
|
|
imports: [
|
|
RouterTestingModule
|
|
]
|
|
})
|
|
.compileComponents();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(FooterComponent);
|
|
component = fixture.componentInstance;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should create', () => {
|
|
expect(component).toBeTruthy();
|
|
});
|
|
|
|
it('should navigate to /impressum when navigateImprint() is called', () => {
|
|
component.navigateImprint();
|
|
expect(router.navigate).toHaveBeenCalledWith(['/impressum']);
|
|
});
|
|
});
|