Skip to content

Commit

Permalink
feat(message-preview): add default fallback if event is not mapped to…
Browse files Browse the repository at this point in the history
… a message (#2367)
  • Loading branch information
domw30 authored Oct 18, 2024
1 parent cb7416d commit b975f93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lib/chat/chat-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ describe(getMessagePreview, () => {

expect(preview).toEqual('Jack: shared a new post');
});

it('returns a system update message if message is null', function () {
const state = new StoreBuilder().withCurrentUser({ id: 'current-user' }).build();

const preview = getMessagePreview(null, state);

expect(preview).toEqual('Admin: System update or change occurred');
});
});

describe(previewDisplayDate, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chat/chat-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function previewDisplayDate(timestamp: number, currentDate = moment()) {

export function getMessagePreview(message: Message, state: RootState) {
if (!message) {
return '';
return 'Admin: System update or change occurred';
}

if (message.sendStatus === MessageSendStatus.FAILED) {
Expand Down

0 comments on commit b975f93

Please sign in to comment.