]> juplo.de Git - demos/kafka/chat/commitdiff
fix: Fixed unit-tests
authorKai Moritz <kai@juplo.de>
Tue, 16 Sep 2025 20:28:18 +0000 (22:28 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 19 Sep 2025 10:52:08 +0000 (12:52 +0200)
src/app/app.component.html
src/app/app.component.spec.ts
src/app/app.component.ts
src/app/chatroom/chatroom.component.spec.ts
src/app/chatroom/chatroom.service.spec.ts
src/app/chatrooms/chatrooms.component.spec.ts
src/app/user/user.component.spec.ts

index 2a45bdd9a3ab496a1bd499e1b15ec684883a55e1..92217a7159a2ed93d64e6d1b930b3567ff96ab79 100644 (file)
@@ -1,4 +1,4 @@
-<div class="container">
+<div class="container header">
   <header class="d-flex flex-wrap justify-content-center pt-3 pb-2 mb-4 border-bottom">
     <a href="/" class="d-flex align-items-center mb-2 mb-md-0 me-md-auto text-dark text-decoration-none">
       <svg class="bi me-2" width="70" height="50"><use xlink:href="#juplo"/></svg>
@@ -11,7 +11,7 @@
     </ul>
   </header>
 </div>
-<div class="container">
+<div class="container content">
   <router-outlet></router-outlet>
 </div> <!-- /container -->
 <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
index c1f36a57fd8b47dca44e1fd5ca27823eb6dec828..97e5fe9e617d1ef010478a4a47c2a04e2538c706 100644 (file)
@@ -20,16 +20,17 @@ describe('AppComponent', () => {
     expect(app).toBeTruthy();
   });
 
-  it(`should have as title 'chatroom-frontend'`, () => {
+  it('should render the header', () => {
     const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.componentInstance;
-    expect(app.title).toEqual('chatroom-frontend');
+    fixture.detectChanges();
+    const compiled = fixture.nativeElement as HTMLElement;
+    expect(compiled.querySelector('div.header')).toBeDefined();
   });
 
-  it('should render title', () => {
+  it('should render the content', () => {
     const fixture = TestBed.createComponent(AppComponent);
     fixture.detectChanges();
     const compiled = fixture.nativeElement as HTMLElement;
-    expect(compiled.querySelector('.content span')?.textContent).toContain('chatroom-frontend app is running!');
+    expect(compiled.querySelector('div.content')).toBeDefined();
   });
 });
index 283aedcf2fd72af3b42e104ff7e3ba039b905768..9a05a567fb1cc9c14339195eda17100ee08a82d2 100644 (file)
@@ -6,5 +6,5 @@ import { Component } from '@angular/core';
   styleUrls: ['./app.component.less']
 })
 export class AppComponent {
-  title = 'Chatroom';
+  title = 'chatroom-frontend';
 }
index 6ebaacfeed87642113a47ac2552c511a819b59f8..ded23f2e2747d0792dd280adc67e1d2d8acc04d5 100644 (file)
@@ -1,5 +1,6 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { RouterTestingModule } from '@angular/router/testing';
 import { ChatroomComponent } from './chatroom.component';
 
 describe('ChatroomComponent', () => {
@@ -8,6 +9,10 @@ describe('ChatroomComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
+      imports: [
+        HttpClientTestingModule,
+        RouterTestingModule,
+      ],
       declarations: [ ChatroomComponent ]
     })
     .compileComponents();
index af0ed87d913450746d635bdb139f18f3096c8ae0..2117adc00417b9b57f05cf58bdbfaa3447bdd115 100644 (file)
@@ -1,12 +1,18 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { TestBed } from '@angular/core/testing';
-
+import { RouterTestingModule } from '@angular/router/testing';
 import { ChatroomService } from './chatroom.service';
 
 describe('ChatroomService', () => {
   let service: ChatroomService;
 
   beforeEach(() => {
-    TestBed.configureTestingModule({});
+    TestBed.configureTestingModule({
+      imports: [
+        HttpClientTestingModule,
+        RouterTestingModule,
+      ],
+    });
     service = TestBed.inject(ChatroomService);
   });
 
index b9a1a6f85d50b4c1972faa97fe4a853ed17a5226..2b795cf36791da3f9602c850703e3e15f8b804c0 100644 (file)
@@ -1,5 +1,5 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-
 import { ChatroomsComponent } from './chatrooms.component';
 
 describe('ChatroomsComponent', () => {
@@ -8,6 +8,7 @@ describe('ChatroomsComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
+      imports: [ HttpClientTestingModule ],
       declarations: [ ChatroomsComponent ]
     })
     .compileComponents();
index aaf6c19aa21551c0ac4fe4202a08bb58c0c238b8..5d815c058a1d36c99fd7d6899b0a805724bf90b6 100644 (file)
@@ -1,5 +1,5 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { ReactiveFormsModule } from '@angular/forms';
 import { UserComponent } from './user.component';
 
 describe('UserComponent', () => {
@@ -8,6 +8,7 @@ describe('UserComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
+      imports: [ ReactiveFormsModule ],
       declarations: [ UserComponent ]
     })
     .compileComponents();
@@ -17,7 +18,7 @@ describe('UserComponent', () => {
     fixture.detectChanges();
   });
 
-  it('should create', () => {
+  it('should be create', () => {
     expect(component).toBeTruthy();
   });
 });