Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
fix: fehler in bisherigen Test behoben (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jstn2004 authored May 10, 2024
1 parent fed69b6 commit e43cedd
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 27 deletions.
16 changes: 5 additions & 11 deletions frontend/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { ToastComponent } from './components/atoms/toast/toast.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent],
declarations: [AppComponent, ToastComponent],
}).compileComponents();
});

Expand All @@ -16,18 +17,11 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
});

it(`should have as title 'frontend'`, () => {
it(`should have as title 'duogradus. | Sammle Schritte, Tritt gegen Freunde an und steig in der Liga auf'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('frontend');
expect(app.title).toEqual('duogradus. | Sammle Schritte, Tritt gegen Freunde an und steig in der Liga auf');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain(
'Hello, frontend'
);
});

});
2 changes: 1 addition & 1 deletion frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { Component } from '@angular/core';
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'frontend';
title = 'duogradus. | Sammle Schritte, Tritt gegen Freunde an und steig in der Liga auf';
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ChallengeButtonComponent } from './challenge-button.component';
import { ChallengeDialogComponent } from 'app/components/organisms/challenge-dialog/challenge-dialog.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('ChallengeButtonComponent', () => {
let component: ChallengeButtonComponent;
let fixture: ComponentFixture<ChallengeButtonComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ChallengeButtonComponent]
declarations: [ChallengeButtonComponent, ChallengeDialogComponent],
imports: [BrowserAnimationsModule],
})
.compileComponents();

Expand All @@ -20,4 +23,13 @@ describe('ChallengeButtonComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should create challenge dialog', () => {
const element: HTMLElement = fixture.nativeElement;
const routerOutlet = element.querySelector('app-challenge-dialog');
expect(routerOutlet).toBeTruthy();
});



});
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TimerComponent } from './timer.component';
import { TimerPipe } from 'app/pipes/timer.pipe';

describe('TimerComponent', () => {
let component: TimerComponent;
let fixture: ComponentFixture<TimerComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TimerComponent],
declarations: [TimerComponent, TimerPipe],
}).compileComponents();

fixture = TestBed.createComponent(TimerComponent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ChallengeDialogComponent } from './challenge-dialog.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('ChallengeDialogComponent', () => {
let component: ChallengeDialogComponent;
Expand All @@ -9,6 +10,7 @@ describe('ChallengeDialogComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ChallengeDialogComponent],
imports: [BrowserAnimationsModule],
}).compileComponents();

fixture = TestBed.createComponent(ChallengeDialogComponent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LoginformComponent } from './loginform.component';
import { InputfieldComponent } from 'app/components/atoms/inputfield/inputfield.component';

describe('LoginformComponent', () => {
let component: LoginformComponent;
let fixture: ComponentFixture<LoginformComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LoginformComponent]
declarations: [LoginformComponent, InputfieldComponent]
})
.compileComponents();

Expand All @@ -20,4 +21,10 @@ describe('LoginformComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should create inputfield', () => {
const element: HTMLElement = fixture.nativeElement;
const inputfield = element.querySelector('app-inputfield');
expect(inputfield).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { RoadmapComponent } from './roadmap.component';
import { ChallengeButtonComponent } from 'app/components/atoms/challenge-button/challenge-button.component';
import { ChallengeDialogComponent } from '../challenge-dialog/challenge-dialog.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('RoadmapComponent', () => {
let component: RoadmapComponent;
let fixture: ComponentFixture<RoadmapComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [RoadmapComponent]
declarations: [RoadmapComponent, ChallengeButtonComponent, ChallengeDialogComponent],
imports: [BrowserAnimationsModule],
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SignupformComponent } from './signupform.component';
import { InputfieldComponent } from 'app/components/atoms/inputfield/inputfield.component';

describe('SignupformComponent', () => {
let component: SignupformComponent;
let fixture: ComponentFixture<SignupformComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [SignupformComponent]
declarations: [SignupformComponent, InputfieldComponent]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { StatisticHeaderComponent } from './statistic-header.component';
import { TimerComponent } from 'app/components/atoms/timer/timer.component';
import { TimerPipe } from 'app/pipes/timer.pipe';

describe('StatisticHeaderComponent', () => {
let component: StatisticHeaderComponent;
let fixture: ComponentFixture<StatisticHeaderComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [StatisticHeaderComponent]
declarations: [StatisticHeaderComponent, TimerComponent, TimerPipe]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { RouterTestingModule } from '@angular/router/testing';
import { AuthenticationpageComponent } from './authenticationpage.component';

describe('AuthenticationpageComponent', () => {
Expand All @@ -8,16 +8,26 @@ describe('AuthenticationpageComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AuthenticationpageComponent]
declarations: [AuthenticationpageComponent],
imports: [RouterTestingModule] // Hier RouterTestingModule importieren, um RouterModule zu simulieren
})
.compileComponents();

});

beforeEach(() => {
fixture = TestBed.createComponent(AuthenticationpageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
it('should create the component', () => {
expect(component).toBeTruthy();
});

it('should contain a router-outlet element', () => {
const element: HTMLElement = fixture.nativeElement;
const routerOutlet = element.querySelector('router-outlet');
expect(routerOutlet).toBeTruthy();
});
});

Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MainpageComponent } from './mainpage.component';
import { StatisticHeaderComponent } from 'app/components/organisms/statistic-header/statistic-header.component';
import { LoaderComponent } from 'app/components/atoms/loader/loader.component';
import { RoadmapComponent } from 'app/components/organisms/roadmap/roadmap.component';
import { TimerComponent } from 'app/components/atoms/timer/timer.component';
import { TimerPipe } from 'app/pipes/timer.pipe';
import { ChallengeButtonComponent } from 'app/components/atoms/challenge-button/challenge-button.component';
import { ChallengeDialogComponent } from 'app/components/organisms/challenge-dialog/challenge-dialog.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('MainpageComponent', () => {
let component: MainpageComponent;
let fixture: ComponentFixture<MainpageComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MainpageComponent]
})
.compileComponents();

declarations: [
MainpageComponent,
StatisticHeaderComponent,
LoaderComponent,
RoadmapComponent,
TimerComponent,
TimerPipe,
ChallengeDialogComponent,
ChallengeButtonComponent
],
imports: [BrowserAnimationsModule],
}).compileComponents();

fixture = TestBed.createComponent(MainpageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>duogradus. | Sammle Schritte, Tritt gegen Freunde an und steig in der Liga auf </title>
<title>duogradus. | Sammle Schritte, Tritt gegen Freunde an und steig in der Liga auf</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="frontend\src\Logo_1_black.ico" type="image/x-icon">
Expand Down

0 comments on commit e43cedd

Please sign in to comment.