diff --git a/frontend/src/app/apartment.service.spec.ts b/frontend/src/app/apartment.service.spec.ts index a9e47b7..f5628b1 100644 --- a/frontend/src/app/apartment.service.spec.ts +++ b/frontend/src/app/apartment.service.spec.ts @@ -1,6 +1,5 @@ import { TestBed } from '@angular/core/testing'; import { HttpClient } from '@angular/common/http'; -import { OAuthService } from 'angular-oauth2-oidc'; import { ApartmentService, Apartment } from './apartment.service'; import { of } from 'rxjs'; import { vi } from 'vitest'; @@ -8,7 +7,6 @@ import { vi } from 'vitest'; describe('ApartmentService', () => { let service: ApartmentService; let mockHttpClient: any; - let mockOAuthService: any; beforeEach(() => { mockHttpClient = { @@ -18,15 +16,10 @@ describe('ApartmentService', () => { delete: vi.fn().mockReturnValue(of({})) }; - mockOAuthService = { - getAccessToken: () => 'mock-token' - }; - TestBed.configureTestingModule({ providers: [ ApartmentService, - { provide: HttpClient, useValue: mockHttpClient }, - { provide: OAuthService, useValue: mockOAuthService } + { provide: HttpClient, useValue: mockHttpClient } ] }); @@ -46,7 +39,7 @@ describe('ApartmentService', () => { service.getApartments().subscribe(data => { expect(data).toEqual(mockApts); }); - expect(mockHttpClient.get).toHaveBeenCalledWith('/api/apartments', expect.any(Object)); + expect(mockHttpClient.get).toHaveBeenCalledWith('/api/apartments'); }); it('should call GET /api/apartments/:id', () => { @@ -56,7 +49,7 @@ describe('ApartmentService', () => { service.getApartment('1').subscribe(data => { expect(data).toEqual(mockApt); }); - expect(mockHttpClient.get).toHaveBeenCalledWith('/api/apartments/1', expect.any(Object)); + expect(mockHttpClient.get).toHaveBeenCalledWith('/api/apartments/1'); }); it('should call POST /api/apartments', () => { @@ -66,7 +59,7 @@ describe('ApartmentService', () => { service.createApartment(mockApt).subscribe(data => { expect(data.id).toBe('2'); }); - expect(mockHttpClient.post).toHaveBeenCalledWith('/api/apartments', mockApt, expect.any(Object)); + expect(mockHttpClient.post).toHaveBeenCalledWith('/api/apartments', mockApt); }); it('should call PUT /api/apartments/:id', () => { @@ -76,11 +69,11 @@ describe('ApartmentService', () => { service.updateApartment('1', mockApt).subscribe(data => { expect(data.name).toBe('Updated Apt'); }); - expect(mockHttpClient.put).toHaveBeenCalledWith('/api/apartments/1', mockApt, expect.any(Object)); + expect(mockHttpClient.put).toHaveBeenCalledWith('/api/apartments/1', mockApt); }); it('should call DELETE /api/apartments/:id', () => { service.deleteApartment('1').subscribe(); - expect(mockHttpClient.delete).toHaveBeenCalledWith('/api/apartments/1', expect.any(Object)); + expect(mockHttpClient.delete).toHaveBeenCalledWith('/api/apartments/1'); }); }); diff --git a/frontend/src/app/apartment.service.ts b/frontend/src/app/apartment.service.ts index 68c165b..9d4f933 100644 --- a/frontend/src/app/apartment.service.ts +++ b/frontend/src/app/apartment.service.ts @@ -1,7 +1,6 @@ import { Injectable, inject } from '@angular/core'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { OAuthService } from 'angular-oauth2-oidc'; export interface Apartment { id?: string; @@ -17,31 +16,24 @@ export interface Apartment { }) export class ApartmentService { private readonly http = inject(HttpClient); - private readonly oauthService = inject(OAuthService); - - private getHeaders(): HttpHeaders { - return new HttpHeaders({ - 'Authorization': 'Bearer ' + this.oauthService.getAccessToken() - }); - } getApartments(): Observable { - return this.http.get('/api/apartments', { headers: this.getHeaders() }); + return this.http.get('/api/apartments'); } getApartment(id: string): Observable { - return this.http.get(`/api/apartments/${id}`, { headers: this.getHeaders() }); + return this.http.get(`/api/apartments/${id}`); } createApartment(apartment: Apartment): Observable { - return this.http.post('/api/apartments', apartment, { headers: this.getHeaders() }); + return this.http.post('/api/apartments', apartment); } updateApartment(id: string, apartment: Apartment): Observable { - return this.http.put(`/api/apartments/${id}`, apartment, { headers: this.getHeaders() }); + return this.http.put(`/api/apartments/${id}`, apartment); } deleteApartment(id: string): Observable { - return this.http.delete(`/api/apartments/${id}`, { headers: this.getHeaders() }); + return this.http.delete(`/api/apartments/${id}`); } }