🔧 Update tests to handle large JSON data and improve file loading error handling

This commit is contained in:
2026-01-29 03:24:38 +00:00
parent a34468275f
commit 9b4b418724

View File

@@ -197,7 +197,7 @@ describe('useGamemasterFiles', () => {
available: [{ filename: 'moves.json', size: 3000 }]
});
await composable.loadStatus();
// Now set up the getMoves to fail
mockClient.getMoves.mockRejectedValueOnce(new Error('Load failed'));
composable.selectedFile.value = 'moves';
@@ -333,13 +333,17 @@ describe('useGamemasterFiles', () => {
});
it('should be true for large files', async () => {
// Create a large string that will split into many lines
const largeContent = Array(15000).fill('line').join('\n');
mockClient.getPokemon.mockResolvedValueOnce(largeContent);
// Create large array that when JSON stringified will have many lines
const largeData = {
items: Array(12000).fill({ id: 1, data: 'test' })
};
mockClient.getPokemon.mockResolvedValueOnce(largeData);
composable.selectedFile.value = 'pokemon';
await composable.loadFile();
// Verify we have many lines (JSON.stringify adds newlines for pretty-print)
expect(composable.fileLines.value.length).toBeGreaterThan(10000);
expect(composable.fileTooLarge.value).toBe(true);
});
});