@@ -229,6 +229,21 @@ describe('groupTransactionsByCategory', () => {
229229 expect ( travelGroup ?. subTotalAmount ) . toBe ( 1000 ) ;
230230 expect ( travelGroup ?. transactions ) . toHaveLength ( 2 ) ;
231231 } ) ;
232+
233+ it ( 'groups transactions with HTML-encoded and decoded category names into a single group' , ( ) => {
234+ const report = createMockReport ( { currency : 'USD' } ) ;
235+ const transactions = [
236+ createMockTransaction ( { transactionID : '1' , category : 'Auto (including Tolls & Parking)' , amount : - 1000 , currency : 'USD' } ) ,
237+ createMockTransaction ( { transactionID : '2' , category : 'Auto (including Tolls & Parking)' , amount : - 2000 , currency : 'USD' } ) ,
238+ ] ;
239+
240+ const result = groupTransactionsByCategory ( transactions , report , mockLocaleCompare ) ;
241+
242+ expect ( result ) . toHaveLength ( 1 ) ;
243+ expect ( result . at ( 0 ) ?. groupKey ) . toBe ( 'Auto (including Tolls & Parking)' ) ;
244+ expect ( result . at ( 0 ) ?. transactions ) . toHaveLength ( 2 ) ;
245+ expect ( result . at ( 0 ) ?. subTotalAmount ) . toBe ( 3000 ) ;
246+ } ) ;
232247} ) ;
233248
234249describe ( 'groupTransactionsByTag' , ( ) => {
@@ -434,4 +449,19 @@ describe('groupTransactionsByTag', () => {
434449 expect ( projectAGroup ?. subTotalAmount ) . toBe ( 1000 ) ;
435450 expect ( projectAGroup ?. transactions ) . toHaveLength ( 2 ) ;
436451 } ) ;
452+
453+ it ( 'groups transactions with HTML-encoded and decoded tag names into a single group' , ( ) => {
454+ const report = createMockReport ( { currency : 'USD' } ) ;
455+ const transactions = [
456+ createMockTransaction ( { transactionID : '1' , tag : 'R&D' , amount : - 1000 , currency : 'USD' } ) ,
457+ createMockTransaction ( { transactionID : '2' , tag : 'R&D' , amount : - 2000 , currency : 'USD' } ) ,
458+ ] ;
459+
460+ const result = groupTransactionsByTag ( transactions , report , mockLocaleCompare ) ;
461+
462+ expect ( result ) . toHaveLength ( 1 ) ;
463+ expect ( result . at ( 0 ) ?. groupKey ) . toBe ( 'R&D' ) ;
464+ expect ( result . at ( 0 ) ?. transactions ) . toHaveLength ( 2 ) ;
465+ expect ( result . at ( 0 ) ?. subTotalAmount ) . toBe ( 3000 ) ;
466+ } ) ;
437467} ) ;
0 commit comments