This commit is contained in:
Bastian Wagner
2026-07-16 15:23:53 +02:00
parent 543e8273a7
commit c03b2e17f5
114 changed files with 7631 additions and 506 deletions

View File

@@ -23,4 +23,49 @@ describe('ItemsPageComponent', () => {
fixture.componentInstance.form.controls.name.setValue('Neues Item');
expect(fixture.componentInstance.form.valid).toBe(true);
});
it('loads items with pagination parameters and changes pages', async () => {
const calls: { search?: string; page?: number; pageSize?: number }[] = [];
await TestBed.configureTestingModule({
imports: [ItemsPageComponent],
providers: [
{
provide: ApiClientService,
useValue: {
items: (query: { search?: string; page?: number; pageSize?: number } = {}) => {
calls.push(query);
return of({
items: [
{
id: `item-${query.page ?? 1}`,
name: 'Item',
description: null,
status: 'active',
version: 1,
createdAt: '2026-07-16T08:00:00.000Z',
updatedAt: '2026-07-16T08:00:00.000Z',
deletedAt: null,
},
],
total: 30,
page: query.page ?? 1,
pageSize: query.pageSize ?? 20,
});
},
},
},
],
}).compileComponents();
const fixture = TestBed.createComponent(ItemsPageComponent);
fixture.detectChanges();
expect(calls[0]).toEqual({ search: '', page: 1, pageSize: 20 });
fixture.componentInstance.goToPage(2);
fixture.detectChanges();
expect(calls[1]).toEqual({ search: '', page: 2, pageSize: 20 });
expect(fixture.componentInstance.page()).toBe(2);
expect((fixture.nativeElement as HTMLElement).textContent).toContain('Seite 2 von 2');
});
});