Skip to content

Commit

Permalink
Merge pull request #36024 from kubabutkiewicz/ts-migration/isReportMe…
Browse files Browse the repository at this point in the history
…ssageAttachmentTest

[No QA] [TS migration] Migrate 'isReportMessageAttachmentTest.js' test to TypeScript
  • Loading branch information
rlinoz authored Feb 15, 2024
2 parents 421bbc5 + c93fa91 commit 38c6c16
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import type {Message} from '@src/types/onyx/ReportAction';
import isReportMessageAttachment from '../../src/libs/isReportMessageAttachment';

describe('isReportMessageAttachment', () => {
it('returns true if a report action is attachment', () => {
const message = {
const message: Message = {
text: '[Attachment]',
html: '<img src="https://www.expensify.com/chat-attachments/1260926113061804740/w_66791ca35b3c34c2a0eda4d065d97c9907cadd61.jpg.1024.jpg" data-expensify-source="https://www.expensify.com/chat-attachments/1260926113061804740/w_66791ca35b3c34c2a0eda4d065d97c9907cadd61.jpg" data-name="rn_image_picker_lib_temp_636b71a8-18fd-41a1-9725-6587ffb207a7.jpg" data-expensify-width="4000" data-expensify-height="3000" />',
type: '',
};
expect(isReportMessageAttachment(message)).toBe(true);
});

it('returns false if a report action is not attachment', () => {
let message = {text: '[Attachment]', html: '<em>[Attachment]</em>'};
let message: Message = {text: '[Attachment]', html: '<em>[Attachment]</em>', type: ''};
expect(isReportMessageAttachment(message)).toBe(false);

message = {text: '[Attachment]', html: '<a href="https://www.google.com" target="_blank" rel="noreferrer noopener">[Attachment]</a>'};
message = {text: '[Attachment]', html: '<a href="https://www.google.com" target="_blank" rel="noreferrer noopener">[Attachment]</a>', type: ''};
expect(isReportMessageAttachment(message)).toBe(false);

message = {text: '[Attachment]', html: '<a href="https://www.google.com/?data-expensify-source=" target="_blank" rel="noreferrer noopener">[Attachment]</a>'};
message = {text: '[Attachment]', html: '<a href="https://www.google.com/?data-expensify-source=" target="_blank" rel="noreferrer noopener">[Attachment]</a>', type: ''};
expect(isReportMessageAttachment(message)).toBe(false);
});
});

0 comments on commit 38c6c16

Please sign in to comment.