fix: make scouting filters immediate and loading state precise

This commit is contained in:
bisco
2026-06-03 22:56:13 +02:00
parent f8244849a3
commit 1b7b4259f4
3 changed files with 69 additions and 12 deletions
+31
View File
@@ -89,6 +89,37 @@ describe('AppComponent', () => {
assert.equal(calls, 1);
});
it('applies quick filters immediately and can clear them with all controls', () => {
const requestedPositions: string[] = [];
const api = {
searchPlayers: (filters: { position: string; league: string }) => {
requestedPositions.push(`${filters.position}:${filters.league}`);
return of({ count: 0, results: [] });
},
} as unknown as PlayerApiService;
const component = new AppComponent(api);
component.setPosition('PG');
component.setLeague('LBA');
component.setPosition('');
component.setLeague('');
assert.deepEqual(requestedPositions, ['PG:', 'PG:LBA', ':LBA', ':']);
});
it('shows the loading placeholder only before results exist', () => {
const api = {
searchPlayers: () => of({ count: samplePlayers.length, results: samplePlayers }),
} as unknown as PlayerApiService;
const component = new AppComponent(api);
component.loading = true;
assert.equal(component.showLoadingPlaceholder, true);
component.players = samplePlayers;
assert.equal(component.showLoadingPlaceholder, false);
});
it('sorts the visible scouting board by selected stat', () => {
const api = {
searchPlayers: () => of({ count: samplePlayers.length, results: samplePlayers }),