diff --git a/tests/unit/TransactionUtilsTest.ts b/tests/unit/TransactionUtilsTest.ts index 6ec8e11d991a..6cf3704aeb09 100644 --- a/tests/unit/TransactionUtilsTest.ts +++ b/tests/unit/TransactionUtilsTest.ts @@ -63,4 +63,33 @@ describe('TransactionUtils', () => { }); }); }); + describe('getPostedDate', () => { + describe('when posted date is undefined', () => { + const transaction = generateTransaction({ + posted: undefined, + }); + + it('returns an empty string', () => { + const expectedResult = ''; + + const result = TransactionUtils.getFormattedPostedDate(transaction); + + expect(result).toEqual(expectedResult); + }); + }); + + describe('when posted date has value with format YYYYMMdd', () => { + const transaction = generateTransaction({ + posted: '20241125', + }); + + it('returns the posted date with the correct format YYYY-MM-dd', () => { + const expectedResult = '2024-11-25'; + + const result = TransactionUtils.getFormattedPostedDate(transaction); + + expect(result).toEqual(expectedResult); + }); + }); + }); });