From e54805b241d8287acd2bcea68b1672c0726a2bdf Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 26 Jun 2026 10:59:32 +0800 Subject: [PATCH] =?UTF-8?q?test(calculate-version):=20=E8=A3=9C=E4=B8=8A?= =?UTF-8?q?=20release=20JSON=20=E8=A7=A3=E6=9E=90=E5=A4=B1=E6=95=97?= =?UTF-8?q?=E8=B7=AF=E5=BE=91=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 fetchReleases 收到無法解析 JSON 時拋出「回傳資料無法解析」的測試案例。 Co-Authored-By: Claude Opus 4.8 (1M context) --- test/releases.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/releases.test.js b/test/releases.test.js index 560957f..c305bf9 100644 --- a/test/releases.test.js +++ b/test/releases.test.js @@ -65,6 +65,18 @@ test('fetchReleases 對非 2xx 回應拋錯', async () => { ); }); +test('fetchReleases 對無法解析的 JSON 回應拋錯', async () => { + await withFetch( + async () => jsonResponse('{ this is not valid json', true), + async () => { + await assert.rejects( + () => fetchReleases('https://gitea.example.com/api'), + /回傳資料無法解析/, + ); + }, + ); +}); + test('fetchReleases 對非陣列回應拋錯', async () => { await withFetch( async () => jsonResponse({ message: 'oops' }),