@@ -50,8 +50,11 @@ const createTestCase = (override = {}): SearchResultType => ({
5050 description : 'Guilty' ,
5151 } ,
5252 ] ,
53+ filingAgency : null ,
54+ filingAgencyAddress : [ ] ,
5355 } ,
5456 ] ,
57+ filingAgency : null ,
5558 } ,
5659 ...override ,
5760} ) ;
@@ -218,4 +221,77 @@ describe('SearchResult component', () => {
218221 // Should still render the charge description
219222 expect ( screen . getByText ( 'Weird Charge' ) ) . toBeInTheDocument ( ) ;
220223 } ) ;
224+
225+ it ( 'displays top-level filing agency when present' , ( ) => {
226+ const testCase = createTestCase ( {
227+ caseSummary : {
228+ caseName : 'State vs. Doe' ,
229+ court : 'Circuit Court' ,
230+ filingAgency : 'Metro PD' ,
231+ charges : [
232+ {
233+ offenseDate : '2022-01-01' ,
234+ filedDate : '2022-01-02' ,
235+ description : 'Theft' ,
236+ statute : '123.456' ,
237+ degree : { code : 'M' , description : 'Misdemeanor' } ,
238+ fine : 0 ,
239+ dispositions : [ ] ,
240+ filingAgency : 'Metro PD' ,
241+ } ,
242+ ] ,
243+ } ,
244+ } ) ;
245+
246+ render ( < SearchResult searchResult = { testCase } /> ) ;
247+
248+ // Top-level Filing Agency should be present
249+ expect ( screen . getByText ( / F i l i n g A g e n c y : / ) ) . toBeInTheDocument ( ) ;
250+ expect ( screen . getByText ( 'Metro PD' ) ) . toBeInTheDocument ( ) ;
251+
252+ // Per-charge filing agency should not be duplicated when top-level present
253+ const chargeAgency = screen . queryAllByText ( / F i l i n g A g e n c y : / ) . length ;
254+ expect ( chargeAgency ) . toBe ( 1 ) ; // only the top-level label
255+ } ) ;
256+
257+ it ( 'displays per-charge filing agencies when they differ and no top-level is set' , ( ) => {
258+ const testCase = createTestCase ( {
259+ caseSummary : {
260+ caseName : 'State vs. Doe' ,
261+ court : 'Circuit Court' ,
262+ charges : [
263+ {
264+ offenseDate : '2022-01-01' ,
265+ filedDate : '2022-01-02' ,
266+ description : 'Charge A' ,
267+ statute : '111' ,
268+ degree : { code : 'M' , description : 'M' } ,
269+ fine : 0 ,
270+ dispositions : [ ] ,
271+ filingAgency : 'Dept A' ,
272+ } ,
273+ {
274+ offenseDate : '2022-02-01' ,
275+ filedDate : '2022-02-02' ,
276+ description : 'Charge B' ,
277+ statute : '222' ,
278+ degree : { code : 'M' , description : 'M' } ,
279+ fine : 0 ,
280+ dispositions : [ ] ,
281+ filingAgency : 'Dept B' ,
282+ } ,
283+ ] ,
284+ } ,
285+ } ) ;
286+
287+ render ( < SearchResult searchResult = { testCase } /> ) ;
288+
289+ // No single top-level filing agency — expect per-charge Filing Agency labels for each charge
290+ const filingLabels = screen . queryAllByText ( / F i l i n g A g e n c y : / ) ;
291+ expect ( filingLabels . length ) . toBeGreaterThanOrEqual ( 2 ) ;
292+
293+ // Both per-charge filing agencies should be present
294+ expect ( screen . getByText ( 'Dept A' ) ) . toBeInTheDocument ( ) ;
295+ expect ( screen . getByText ( 'Dept B' ) ) . toBeInTheDocument ( ) ;
296+ } ) ;
221297} ) ;
0 commit comments