fix: svelte check
This commit is contained in:
@@ -184,7 +184,7 @@ describe('submitScoreSchema', () => {
|
|||||||
test('accepts valid score submission', () => {
|
test('accepts valid score submission', () => {
|
||||||
const valid = {
|
const valid = {
|
||||||
matchGameId: uuid1,
|
matchGameId: uuid1,
|
||||||
scores: [{ participantId: uuid2, score: 1000000 }]
|
scores: [{ playerId: uuid2, score: 1000000 }]
|
||||||
};
|
};
|
||||||
expect(submitScoreSchema.parse(valid)).toBeTruthy();
|
expect(submitScoreSchema.parse(valid)).toBeTruthy();
|
||||||
});
|
});
|
||||||
@@ -193,7 +193,7 @@ describe('submitScoreSchema', () => {
|
|||||||
expect(() =>
|
expect(() =>
|
||||||
submitScoreSchema.parse({
|
submitScoreSchema.parse({
|
||||||
matchGameId: uuid1,
|
matchGameId: uuid1,
|
||||||
scores: [{ participantId: uuid2, score: -1 }]
|
scores: [{ playerId: uuid2, score: -1 }]
|
||||||
})
|
})
|
||||||
).toThrow();
|
).toThrow();
|
||||||
});
|
});
|
||||||
@@ -204,7 +204,7 @@ describe('submitScoreSchema', () => {
|
|||||||
|
|
||||||
test('rejects scores array over 16 entries', () => {
|
test('rejects scores array over 16 entries', () => {
|
||||||
const scores = Array.from({ length: 17 }, (_, i) => ({
|
const scores = Array.from({ length: 17 }, (_, i) => ({
|
||||||
participantId: `550e8400-e29b-41d4-a716-4466554400${String(i).padStart(2, '0')}`,
|
playerId: `550e8400-e29b-41d4-a716-4466554400${String(i).padStart(2, '0')}`,
|
||||||
score: 100
|
score: 100
|
||||||
}));
|
}));
|
||||||
expect(() => submitScoreSchema.parse({ matchGameId: uuid1, scores })).toThrow();
|
expect(() => submitScoreSchema.parse({ matchGameId: uuid1, scores })).toThrow();
|
||||||
@@ -214,7 +214,7 @@ describe('submitScoreSchema', () => {
|
|||||||
expect(() =>
|
expect(() =>
|
||||||
submitScoreSchema.parse({
|
submitScoreSchema.parse({
|
||||||
matchGameId: 'bad',
|
matchGameId: 'bad',
|
||||||
scores: [{ participantId: uuid2, score: 100 }]
|
scores: [{ playerId: uuid2, score: 100 }]
|
||||||
})
|
})
|
||||||
).toThrow();
|
).toThrow();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,8 +40,17 @@ export const createInviteSchema = z.object({
|
|||||||
|
|
||||||
// ── Score submission ──
|
// ── Score submission ──
|
||||||
const scoreEntrySchema = z.object({
|
const scoreEntrySchema = z.object({
|
||||||
participantId: z.string().uuid(),
|
playerId: z.string().uuid(),
|
||||||
score: z.number().int().min(0)
|
score: z.number().int().min(0),
|
||||||
|
accuracy: z.number().min(0).max(100).optional(),
|
||||||
|
maxCombo: z.number().int().min(0).optional(),
|
||||||
|
count300: z.number().int().min(0).optional(),
|
||||||
|
count100: z.number().int().min(0).optional(),
|
||||||
|
count50: z.number().int().min(0).optional(),
|
||||||
|
countMiss: z.number().int().min(0).optional(),
|
||||||
|
mods: z.array(z.string()).optional(),
|
||||||
|
passed: z.boolean().optional(),
|
||||||
|
pp: z.number().min(0).nullable().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const submitScoreSchema = z.object({
|
export const submitScoreSchema = z.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user