@@ -145,7 +145,7 @@ describe('CaseProcessor', () => {
145145 describe ( 'buildCaseSummary' , ( ) => {
146146 const { buildCaseSummary } = CaseProcessor as any ;
147147
148- it ( 'extracts the earliest LPSD Event.EventDate and sets arrestOrCitationDate as ISO string ' , ( ) => {
148+ it ( 'extracts the earliest LPSD Event.EventDate and sets arrestOrCitationDate and type as Arrest ' , ( ) => {
149149 const rawData = {
150150 summary : {
151151 CaseSummaryHeader : {
@@ -186,13 +186,43 @@ describe('CaseProcessor', () => {
186186
187187 expect ( summary ) . not . toBeNull ( ) ;
188188 expect ( summary ?. arrestOrCitationDate ) . toBeDefined ( ) ;
189+ expect ( summary ?. arrestOrCitationType ) . toBe ( 'Arrest' ) ;
189190
190191 // Expected earliest LPSD date is 02/10/2021 -> construct UTC Date and compare ISO
191192 const expectedIso = new Date ( Date . UTC ( 2021 , 1 , 10 ) ) . toISOString ( ) ;
192193 expect ( summary ?. arrestOrCitationDate ) . toBe ( expectedIso ) ;
193194 } ) ;
194195
195- it ( 'does not set arrestOrCitationDate when no LPSD events present' , ( ) => {
196+ it ( 'selects CIT over LPSD if earlier (sets type Citation)' , ( ) => {
197+ const rawData = {
198+ summary : {
199+ CaseSummaryHeader : {
200+ Style : 'State vs. Someone' ,
201+ Heading : 'Circuit Court' ,
202+ CaseId : 'case-234' ,
203+ } ,
204+ } ,
205+ charges : { Charges : [ ] } ,
206+ dispositionEvents : { Events : [ ] } ,
207+ caseEvents : {
208+ Events : [
209+ { Event : { TypeId : { Word : 'LPSD' } , EventDate : '03/15/2021' } } ,
210+ { Event : { TypeId : { Word : 'CIT' } , EventDate : '02/09/2021' } } ,
211+ ] ,
212+ } ,
213+ } ;
214+
215+ const summary = buildCaseSummary ( rawData ) ;
216+
217+ expect ( summary ) . not . toBeNull ( ) ;
218+ expect ( summary ?. arrestOrCitationDate ) . toBeDefined ( ) ;
219+ expect ( summary ?. arrestOrCitationType ) . toBe ( 'Citation' ) ;
220+
221+ const expectedIso = new Date ( Date . UTC ( 2021 , 1 , 9 ) ) . toISOString ( ) ;
222+ expect ( summary ?. arrestOrCitationDate ) . toBe ( expectedIso ) ;
223+ } ) ;
224+
225+ it ( 'does not set arrestOrCitationDate when no LPSD/CIT events present' , ( ) => {
196226 const rawData = {
197227 summary : {
198228 CaseSummaryHeader : {
@@ -216,6 +246,7 @@ describe('CaseProcessor', () => {
216246
217247 expect ( summary ) . not . toBeNull ( ) ;
218248 expect ( summary ?. arrestOrCitationDate ) . toBeUndefined ( ) ;
249+ expect ( summary ?. arrestOrCitationType ) . toBeUndefined ( ) ;
219250 } ) ;
220251
221252 it ( 'ignores malformed LPSD Event.EventDate values' , ( ) => {
@@ -243,6 +274,7 @@ describe('CaseProcessor', () => {
243274 const summary = buildCaseSummary ( rawData ) ;
244275 expect ( summary ) . not . toBeNull ( ) ;
245276 expect ( summary ?. arrestOrCitationDate ) . toBeUndefined ( ) ;
277+ expect ( summary ?. arrestOrCitationType ) . toBeUndefined ( ) ;
246278 } ) ;
247279 } ) ;
248280} ) ;
0 commit comments