@@ -64,4 +64,36 @@ describe('retrieveQueryById - Fetch Query Record by ID from API', () => {
64
64
65
65
expect ( result ) . toBeNull ( ) ;
66
66
} ) ;
67
+ it ( 'should return null if API response is missing the response field' , async ( ) => {
68
+ mockCore . http . get . mockResolvedValue ( { } ) ;
69
+
70
+ const result = await retrieveQueryById ( mockCore , undefined , testStart , testEnd , testId ) ;
71
+
72
+ expect ( result ) . toBeNull ( ) ;
73
+ } ) ;
74
+
75
+ it ( 'should return null if API response contains an unexpected structure' , async ( ) => {
76
+ mockCore . http . get . mockResolvedValue ( { unexpectedKey : { } } ) ;
77
+
78
+ const result = await retrieveQueryById ( mockCore , undefined , testStart , testEnd , testId ) ;
79
+
80
+ expect ( result ) . toBeNull ( ) ;
81
+ } ) ;
82
+
83
+ it ( 'should return null if API request fails' , async ( ) => {
84
+ mockCore . http . get . mockRejectedValue ( new Error ( 'API error' ) ) ;
85
+
86
+ const result = await retrieveQueryById ( mockCore , undefined , testStart , testEnd , testId ) ;
87
+
88
+ expect ( result ) . toBeNull ( ) ;
89
+ } ) ;
90
+
91
+ it ( 'should handle cases where API returns an empty object instead of expected response structure' , async ( ) => {
92
+ mockCore . http . get . mockResolvedValue ( { } ) ;
93
+
94
+ const result = await retrieveQueryById ( mockCore , undefined , testStart , testEnd , testId ) ;
95
+
96
+ expect ( result ) . toBeNull ( ) ;
97
+ } ) ;
98
+
67
99
} ) ;
0 commit comments