test(calculate-version): 補上 release JSON 解析失敗路徑測試
新增 fetchReleases 收到無法解析 JSON 時拋出「回傳資料無法解析」的測試案例。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
66d2c4b35f
commit
e54805b241
@@ -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 () => {
|
test('fetchReleases 對非陣列回應拋錯', async () => {
|
||||||
await withFetch(
|
await withFetch(
|
||||||
async () => jsonResponse({ message: 'oops' }),
|
async () => jsonResponse({ message: 'oops' }),
|
||||||
|
|||||||
Reference in New Issue
Block a user