From 0bae4763a9f553809ed4b02e82835d48f14792c7 Mon Sep 17 00:00:00 2001 From: Gugu8 Date: Wed, 9 Sep 2026 11:36:18 +1200 Subject: [PATCH] Enhance tests for assertCompleteAxiomResponse --- .../__tests__/axiom-complete-response.test.ts | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/common/src/util/__tests__/axiom-complete-response.test.ts b/common/src/util/__tests__/axiom-complete-response.test.ts index 14b3211977..6e1ecd953b 100644 --- a/common/src/util/__tests__/axiom-complete-response.test.ts +++ b/common/src/util/__tests__/axiom-complete-response.test.ts @@ -44,12 +44,39 @@ describe('isCompleteAxiomResponse', () => { }) describe('assertCompleteAxiomResponse', () => { - test('names the caller in the error', () => { - expect(() => - assertCompleteAxiomResponse({ status: { isPartial: true } }, 'hour 12'), - ).toThrow(/^hour 12: Axiom returned a partial or statusless answer/) + test('does not throw for a complete response', () => { expect(() => assertCompleteAxiomResponse({ status: { isPartial: false } }, 'hour 12'), ).not.toThrow() }) + + test('throws for a partial response with the caller name', () => { + expect(() => + assertCompleteAxiomResponse({ status: { isPartial: true } }, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + }) + + test('throws for a statusless response — not just partials', () => { + expect(() => + assertCompleteAxiomResponse({ buckets: { totals: [] } }, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + + expect(() => + assertCompleteAxiomResponse({ status: {} }, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + + expect(() => + assertCompleteAxiomResponse({ status: null }, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + }) + + test('throws for non-object inputs', () => { + expect(() => + assertCompleteAxiomResponse(null, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + + expect(() => + assertCompleteAxiomResponse(undefined, 'hour 12'), + ).toThrow(/^hour 12: Axiom returned a partial or statusless answer$/) + }) })