Skip to content

Commit

Permalink
Resolve linkify error (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamDotCom authored Mar 27, 2023
1 parent 1327a09 commit b692fce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/store/messages/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
editMessage,
uploadFileMessage,
receiveNewMessage,
getPreview,
} from './saga';

import { rootReducer } from '..';
Expand Down Expand Up @@ -793,4 +794,12 @@ describe('messages saga', () => {
'the-third-message-id': { id: 'the-third-message-id', message: 'the third message' },
});
});

describe('getPreview', () => {
it('guards from empty messages (like when you upload a file)', () => {
const generator = getPreview(null);

expect(generator.next().value).toEqual(undefined);
});
});
});
4 changes: 3 additions & 1 deletion src/store/messages/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ export function* receiveNewMessage(action) {
);
}

function* getPreview(message) {
export function* getPreview(message) {
if (!message) return;

const link: linkifyType[] = extractLink(message);
if (!link.length) return;

Expand Down

0 comments on commit b692fce

Please sign in to comment.