add BrandService and ProductService with basic HTTP methods and tests

This commit is contained in:
Vincent Guillet
2025-10-14 14:53:07 +02:00
parent f2f855bc70
commit f04f9fd93f
4 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { BrandService } from './brand.service';
describe('BrandService', () => {
let service: BrandService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(BrandService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,16 @@
import {inject, Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Brand} from '../../models/brand/brand';
@Injectable({
providedIn: 'root'
})
export class BrandService {
private readonly http = inject(HttpClient);
private readonly BASE_URL = 'http://localhost:3000/brands';
getBrands() {
return this.http.get<Brand[]>(this.BASE_URL, {withCredentials: true});
}
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ProductService } from './product.service';
describe('ProductService', () => {
let service: ProductService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ProductService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,13 @@
import {inject, Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class ProductService {
private readonly http = inject(HttpClient);
private readonly BASE_URL = 'http://localhost:3000/api/products';
constructor() { }
}