Files
lmnp-organizer/frontend/src/app/services/furniture-inventory.service.spec.ts
T

31 lines
1.1 KiB
TypeScript

import { provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { FurnitureInventoryService } from './furniture-inventory.service';
describe('FurnitureInventoryService', () => {
let service: FurnitureInventoryService;
let http: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideHttpClient(), provideHttpClientTesting()],
});
service = TestBed.inject(FurnitureInventoryService);
http = TestBed.inject(HttpTestingController);
});
afterEach(() => http.verify());
it('uses the versioned furniture-inventory contract', () => {
service.getInventory('lease-1').subscribe();
http.expectOne('/api/leases/lease-1/inventory').flush({});
service.saveInventory('lease-1', { version: 4, lines: [] }).subscribe();
const request = http.expectOne('/api/leases/lease-1/inventory');
expect(request.request.method).toBe('PUT');
expect(request.request.body).toEqual({ version: 4, lines: [] });
request.flush({});
});
});