Skip to content

Commit 49d7ebe

Browse files
Refactor: Improve type safety and test coverage
Co-authored-by: erik <erik@veefriends.com>
1 parent 9a22bd3 commit 49d7ebe

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

src/core/Gracket.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ describe('Gracket', () => {
464464

465465
it('should trigger onScoreUpdate callback', () => {
466466
let callbackCalled = false;
467-
let callbackData: any = null;
467+
let callbackData: { r: number; g: number; t: number; score: number } | null = null;
468468

469469
const gracketWithCallback = new Gracket(container, {
470470
src: JSON.parse(JSON.stringify(mutableData)),
@@ -765,7 +765,7 @@ describe('Gracket', () => {
765765
});
766766

767767
it('should pass correct parameters to onScoreUpdate', () => {
768-
const capturedParams: any[] = [];
768+
const capturedParams: Array<{ r: number; g: number; t: number; score: number }> = [];
769769

770770
const data: TournamentData = [
771771
[

src/integration.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,7 @@ describe('Integration Tests - Complete Workflows', () => {
213213
const tournamentData = generateTournamentWithByes(teams, 'top-seeds');
214214
const gracket = new Gracket(container, { src: tournamentData });
215215

216-
let roundsCompleted = 0;
217-
218-
// Monitor round completion
219-
const onRoundComplete = (r: number) => {
220-
roundsCompleted++;
221-
222-
// Auto-advance when round completes
223-
if (gracket.isRoundComplete(r)) {
224-
gracket.advanceRound(r, {
225-
tieBreaker: 'higher-seed',
226-
createRounds: true
227-
});
228-
}
229-
};
230-
231-
// Manually attach callback logic
216+
// Get initial data
232217
const data = gracket.getData();
233218

234219
// Score round 1

src/utils/byes.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ describe('byes utilities', () => {
423423
const tournament = generateTournamentWithByes(teams, 'top-seeds');
424424

425425
// Each round should have placeholder teams with IDs
426-
tournament.forEach((round, rIdx) => {
427-
round.forEach((game, gIdx) => {
426+
tournament.forEach((round) => {
427+
round.forEach((game) => {
428428
game.forEach(team => {
429429
expect(team.name).toBeDefined();
430430
expect(team.seed).toBeDefined();

src/utils/tournament.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe('tournament utilities', () => {
234234

235235
it('should throw error for unknown strategy', () => {
236236
expect(() => {
237-
applyTieBreaker(team1, team2, 'invalid' as any);
237+
applyTieBreaker(team1, team2, 'invalid' as 'higher-seed' | 'lower-seed' | 'callback');
238238
}).toThrow('Unknown tie-breaker strategy');
239239
});
240240

0 commit comments

Comments
 (0)