Files
teamwallet/myteamwallet_frontend_modern/src/app/features/public-team/public-team.spec.ts
Bastian Wagner 6bea4f766a first commit
2026-07-31 21:02:47 +02:00

39 lines
1.5 KiB
TypeScript

import { TestBed } from '@angular/core/testing';
import { ActivatedRoute, convertToParamMap, provideRouter } from '@angular/router';
import { of } from 'rxjs';
import { PublicTeamApi } from '../../core/team/public-team-api';
import { PublicTeam } from './public-team';
describe('PublicTeam', () => {
it('renders the combined public team response without a separate penalty request', async () => {
const team = {
name: 'Team A',
balance: 120,
outstanding: 15,
players: [
{ id: 7, firstName: 'Bea', lastName: 'Test', balance: -5, active: true },
{ id: 8, firstName: 'Inaktiv', lastName: 'Mitglied', balance: 0, active: false },
],
penalties: [{ id: 1, description: 'Zu spät', amount: 5 }],
};
await TestBed.configureTestingModule({
imports: [PublicTeam],
providers: [
provideRouter([]),
{
provide: ActivatedRoute,
useValue: { snapshot: { paramMap: convertToParamMap({ token: 'public-token' }) } },
},
{ provide: PublicTeamApi, useValue: { loadTeam: vi.fn(() => of(team)) } },
],
}).compileComponents();
const fixture = TestBed.createComponent(PublicTeam);
fixture.detectChanges();
expect(fixture.nativeElement.textContent).toContain('Team A');
expect(fixture.nativeElement.textContent).toContain('Bea Test');
expect(fixture.nativeElement.textContent).not.toContain('Inaktiv Mitglied');
expect(fixture.nativeElement.textContent).toContain('Zu spät');
});
});