Skip to content

Commit 39124cf

Browse files
committed
chore: add tests
1 parent f4da520 commit 39124cf

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/unit/ReportUtilsTest.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,50 @@ describe('ReportUtils', () => {
721721
expect(getReportName(expenseChatReport)).toEqual("Ragnar Lothbrok's expenses");
722722
});
723723
});
724+
725+
describe('Fallback scenarios', () => {
726+
test('should fallback to report.reportName when primary name generation returns empty string', () => {
727+
const reportWithFallbackName: Report = {
728+
reportID: '3',
729+
reportName: 'Custom Report Name',
730+
ownerAccountID: undefined,
731+
participants: {},
732+
policyID: undefined,
733+
chatType: undefined,
734+
};
735+
736+
const result = getReportName(reportWithFallbackName);
737+
expect(result).toBe('Custom Report Name');
738+
});
739+
740+
test('should return empty string when both primary name generation and reportName are empty', () => {
741+
const reportWithoutName: Report = {
742+
reportID: '4',
743+
reportName: '',
744+
ownerAccountID: undefined,
745+
participants: {},
746+
policyID: undefined,
747+
chatType: undefined,
748+
};
749+
750+
const result = getReportName(reportWithoutName);
751+
expect(result).toBe('');
752+
});
753+
754+
test('should return empty string when reportName is undefined', () => {
755+
const reportWithUndefinedName: Report = {
756+
reportID: '5',
757+
reportName: undefined,
758+
ownerAccountID: undefined,
759+
participants: {},
760+
policyID: undefined,
761+
chatType: undefined,
762+
};
763+
764+
const result = getReportName(reportWithUndefinedName);
765+
expect(result).toBe('');
766+
});
767+
});
724768
});
725769

726770
describe('requiresAttentionFromCurrentUser', () => {

0 commit comments

Comments
 (0)