From f04f9fd93f649c8215de43fd0959cb8356c142f1 Mon Sep 17 00:00:00 2001 From: Vincent Guillet Date: Tue, 14 Oct 2025 14:53:07 +0200 Subject: [PATCH] add BrandService and ProductService with basic HTTP methods and tests --- .../src/app/services/brand/brand.service.spec.ts | 16 ++++++++++++++++ client/src/app/services/brand/brand.service.ts | 16 ++++++++++++++++ .../app/services/product/product.service.spec.ts | 16 ++++++++++++++++ .../src/app/services/product/product.service.ts | 13 +++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 client/src/app/services/brand/brand.service.spec.ts create mode 100644 client/src/app/services/brand/brand.service.ts create mode 100644 client/src/app/services/product/product.service.spec.ts create mode 100644 client/src/app/services/product/product.service.ts diff --git a/client/src/app/services/brand/brand.service.spec.ts b/client/src/app/services/brand/brand.service.spec.ts new file mode 100644 index 0000000..9b88b26 --- /dev/null +++ b/client/src/app/services/brand/brand.service.spec.ts @@ -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(); + }); +}); diff --git a/client/src/app/services/brand/brand.service.ts b/client/src/app/services/brand/brand.service.ts new file mode 100644 index 0000000..51f8096 --- /dev/null +++ b/client/src/app/services/brand/brand.service.ts @@ -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(this.BASE_URL, {withCredentials: true}); + } +} diff --git a/client/src/app/services/product/product.service.spec.ts b/client/src/app/services/product/product.service.spec.ts new file mode 100644 index 0000000..d5c493e --- /dev/null +++ b/client/src/app/services/product/product.service.spec.ts @@ -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(); + }); +}); diff --git a/client/src/app/services/product/product.service.ts b/client/src/app/services/product/product.service.ts new file mode 100644 index 0000000..af21b65 --- /dev/null +++ b/client/src/app/services/product/product.service.ts @@ -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() { } +}