Skip to content

Commit

Permalink
Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
almirhodzic committed Feb 24, 2024
1 parent 7ecab38 commit 11d9899
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/app/services/cart.servic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { CartService } from './cart.service';
import { ToastrModule, ToastrService } from 'ngx-toastr';
import { HttpClientModule } from '@angular/common/http';

describe('CartService', () => {
let service: CartService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
ToastrModule.forRoot(),
HttpClientModule
],
providers: [
CartService,
]
});
service = TestBed.inject(CartService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('#should format a value to the ch-CH price format', () => {
const result = service.formatPrice(594);
expect(result).toBe('Fr. 594.–');
});

it('#should return a placeholder for instock icon color', () => {
const result = service.inStock(10);
expect(result).toBe('bi-check-circle-fill stockgreen');
});
});
14 changes: 14 additions & 0 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

0 comments on commit 11d9899

Please sign in to comment.