add BrandService and ProductService with basic HTTP methods and tests
This commit is contained in:
16
client/src/app/services/brand/brand.service.spec.ts
Normal file
16
client/src/app/services/brand/brand.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
16
client/src/app/services/brand/brand.service.ts
Normal file
16
client/src/app/services/brand/brand.service.ts
Normal 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});
|
||||
}
|
||||
}
|
||||
16
client/src/app/services/product/product.service.spec.ts
Normal file
16
client/src/app/services/product/product.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
13
client/src/app/services/product/product.service.ts
Normal file
13
client/src/app/services/product/product.service.ts
Normal 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() { }
|
||||
}
|
||||
Reference in New Issue
Block a user