1- import { createUnreportedExpenseSections } from '@libs/TransactionUtils' ;
1+ import { createUnreportedExpenses } from '@libs/TransactionUtils' ;
22import CONST from '@src/CONST' ;
33import type Transaction from '@src/types/onyx/Transaction' ;
44
@@ -24,7 +24,7 @@ function generateTransaction(values: Partial<Transaction> = {}): Transaction {
2424}
2525
2626describe ( 'AddUnreportedExpense' , ( ) => {
27- describe ( 'createUnreportedExpenseSections ' , ( ) => {
27+ describe ( 'createUnreportedExpenses ' , ( ) => {
2828 it ( 'should mark transactions with DELETE pendingAction as disabled' , ( ) => {
2929 const normalTransaction = generateTransaction ( {
3030 transactionID : '123' ,
@@ -41,16 +41,15 @@ describe('AddUnreportedExpense', () => {
4141 } ) ;
4242
4343 const transactions = [ normalTransaction , deletedTransaction ] ;
44- const sections = createUnreportedExpenseSections ( transactions ) ;
44+ const unreportedExpenses = createUnreportedExpenses ( transactions ) ;
4545
46- // Should create one section
47- expect ( sections ) . toHaveLength ( 2 ) ;
46+ expect ( unreportedExpenses ) . toHaveLength ( 2 ) ;
4847
49- const processedNormalTransaction = sections . find ( ( t ) => t . transactionID === '123' ) ;
48+ const processedNormalTransaction = unreportedExpenses . find ( ( t ) => t . transactionID === '123' ) ;
5049 expect ( processedNormalTransaction ?. isDisabled ) . toBe ( false ) ;
5150 expect ( processedNormalTransaction ?. keyForList ) . toBe ( '123' ) ;
5251
53- const processedDeletedTransaction = sections . find ( ( t ) => t . transactionID === '456' ) ;
52+ const processedDeletedTransaction = unreportedExpenses . find ( ( t ) => t . transactionID === '456' ) ;
5453 expect ( processedDeletedTransaction ?. isDisabled ) . toBe ( true ) ;
5554 expect ( processedDeletedTransaction ?. keyForList ) . toBe ( '456' ) ;
5655 } ) ;
@@ -78,11 +77,11 @@ describe('AddUnreportedExpense', () => {
7877 } ) ;
7978
8079 const transactions = [ normalTransaction , updateTransaction , addTransaction ] ;
81- const sections = createUnreportedExpenseSections ( transactions ) ;
80+ const unreportedExpenses = createUnreportedExpenses ( transactions ) ;
8281
83- expect ( sections ) . toHaveLength ( 3 ) ;
82+ expect ( unreportedExpenses ) . toHaveLength ( 3 ) ;
8483 // eslint-disable-next-line unicorn/no-array-for-each
85- sections . forEach ( ( transaction ) => {
84+ unreportedExpenses . forEach ( ( transaction ) => {
8685 expect ( transaction . isDisabled ) . toBe ( false ) ;
8786 } ) ;
8887 } ) ;
@@ -103,11 +102,11 @@ describe('AddUnreportedExpense', () => {
103102 } ) ;
104103
105104 const transactions = [ deletedTransaction1 , deletedTransaction2 ] ;
106- const sections = createUnreportedExpenseSections ( transactions ) ;
105+ const unreportedExpenses = createUnreportedExpenses ( transactions ) ;
107106
108- expect ( sections ) . toHaveLength ( 2 ) ;
107+ expect ( unreportedExpenses ) . toHaveLength ( 2 ) ;
109108 // eslint-disable-next-line unicorn/no-array-for-each
110- sections . forEach ( ( transaction ) => {
109+ unreportedExpenses . forEach ( ( transaction ) => {
111110 expect ( transaction . isDisabled ) . toBe ( true ) ;
112111 expect ( transaction . pendingAction ) . toBe ( CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE ) ;
113112 } ) ;
@@ -119,10 +118,10 @@ describe('AddUnreportedExpense', () => {
119118 } ) ;
120119
121120 const transactions = [ normalTransaction , undefined ] ;
122- const result = createUnreportedExpenseSections ( transactions ) ;
121+ const unreportedExpenses = createUnreportedExpenses ( transactions ) ;
123122
124- expect ( result ) . toHaveLength ( 1 ) ;
125- expect ( result [ 0 ] . transactionID ) . toBe ( '123' ) ;
123+ expect ( unreportedExpenses ) . toHaveLength ( 1 ) ;
124+ expect ( unreportedExpenses . at ( 0 ) ? .transactionID ) . toBe ( '123' ) ;
126125 } ) ;
127126 } ) ;
128127} ) ;
0 commit comments