Skip to content

Commit

Permalink
add unit test for getFormattedPostedDate
Browse files Browse the repository at this point in the history
  • Loading branch information
mkzie2 committed Nov 27, 2024
1 parent 1f2b130 commit 4b86262
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/unit/TransactionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

0 comments on commit 4b86262

Please sign in to comment.