test: add Next.js 16 params Promise handling regression tests

This commit is contained in:
2026-03-31 00:52:04 -07:00
parent b8d90897a4
commit 1729dacdec
+32
View File
@@ -125,4 +125,36 @@ describe('ID Validation', () => {
expect(isNaN(playerId)).toBe(true); expect(isNaN(playerId)).toBe(true);
}); });
}); });
describe('Next.js 16 params handling', () => {
test('should handle params as Promise (Next.js 16 requirement)', async () => {
// In Next.js 16, params is a Promise
const params = Promise.resolve({ id: '123' });
// This is how Next.js 16 expects params to be handled
const { id } = await params;
const parsedId = parseInt(id, 10);
expect(parsedId).toBe(123);
expect(isNaN(parsedId)).toBe(false);
});
test('should handle invalid ID in Next.js 16 params', async () => {
const params = Promise.resolve({ id: 'invalid' });
const { id } = await params;
const parsedId = parseInt(id, 10);
expect(isNaN(parsedId)).toBe(true);
});
test('should handle empty ID in Next.js 16 params', async () => {
const params = Promise.resolve({ id: '' });
const { id } = await params;
const parsedId = parseInt(id, 10);
expect(isNaN(parsedId)).toBe(true);
});
});
}); });