🔧 Update tests to handle large JSON data and improve file loading error handling
This commit is contained in:
@@ -197,7 +197,7 @@ describe('useGamemasterFiles', () => {
|
|||||||
available: [{ filename: 'moves.json', size: 3000 }]
|
available: [{ filename: 'moves.json', size: 3000 }]
|
||||||
});
|
});
|
||||||
await composable.loadStatus();
|
await composable.loadStatus();
|
||||||
|
|
||||||
// Now set up the getMoves to fail
|
// Now set up the getMoves to fail
|
||||||
mockClient.getMoves.mockRejectedValueOnce(new Error('Load failed'));
|
mockClient.getMoves.mockRejectedValueOnce(new Error('Load failed'));
|
||||||
composable.selectedFile.value = 'moves';
|
composable.selectedFile.value = 'moves';
|
||||||
@@ -333,13 +333,17 @@ describe('useGamemasterFiles', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be true for large files', async () => {
|
it('should be true for large files', async () => {
|
||||||
// Create a large string that will split into many lines
|
// Create large array that when JSON stringified will have many lines
|
||||||
const largeContent = Array(15000).fill('line').join('\n');
|
const largeData = {
|
||||||
mockClient.getPokemon.mockResolvedValueOnce(largeContent);
|
items: Array(12000).fill({ id: 1, data: 'test' })
|
||||||
|
};
|
||||||
|
mockClient.getPokemon.mockResolvedValueOnce(largeData);
|
||||||
composable.selectedFile.value = 'pokemon';
|
composable.selectedFile.value = 'pokemon';
|
||||||
|
|
||||||
await composable.loadFile();
|
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);
|
expect(composable.fileTooLarge.value).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user