From 9b4b41872463df2b7327d7c91c9cfaa019294b4a Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 03:24:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Update=20tests=20to=20handle=20l?= =?UTF-8?q?arge=20JSON=20data=20and=20improve=20file=20loading=20error=20h?= =?UTF-8?q?andling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/composables/useGamemasterFiles.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/websites/pokedex.online/tests/unit/composables/useGamemasterFiles.test.js b/code/websites/pokedex.online/tests/unit/composables/useGamemasterFiles.test.js index e11faad..354a59c 100644 --- a/code/websites/pokedex.online/tests/unit/composables/useGamemasterFiles.test.js +++ b/code/websites/pokedex.online/tests/unit/composables/useGamemasterFiles.test.js @@ -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); }); });