From 312114e16abf5e39a66aa7e0c493a0db9177a05a Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Wed, 7 Feb 2024 14:46:47 +0100 Subject: [PATCH 1/2] ref: move isReportMessageAttachmentTest to TS --- src/types/onyx/ReportAction.ts | 2 +- ...ageAttachmentTest.js => isReportMessageAttachmentTest.ts} | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename tests/unit/{isReportMessageAttachmentTest.js => isReportMessageAttachmentTest.ts} (87%) diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 3ec98fd43178..1b420c7dda54 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -10,7 +10,7 @@ import type {Receipt} from './Transaction'; type Message = { /** The type of the action item fragment. Used to render a corresponding component */ - type: string; + type?: string; /** The text content of the fragment. */ text: string; diff --git a/tests/unit/isReportMessageAttachmentTest.js b/tests/unit/isReportMessageAttachmentTest.ts similarity index 87% rename from tests/unit/isReportMessageAttachmentTest.js rename to tests/unit/isReportMessageAttachmentTest.ts index 8338513a7e7e..3014111d5c2c 100644 --- a/tests/unit/isReportMessageAttachmentTest.js +++ b/tests/unit/isReportMessageAttachmentTest.ts @@ -1,8 +1,9 @@ +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: '', }; @@ -10,7 +11,7 @@ describe('isReportMessageAttachment', () => { }); it('returns false if a report action is not attachment', () => { - let message = {text: '[Attachment]', html: '[Attachment]'}; + let message: Message = {text: '[Attachment]', html: '[Attachment]'}; expect(isReportMessageAttachment(message)).toBe(false); message = {text: '[Attachment]', html: '[Attachment]'}; From d99382347d316b2696a7c30c2066422db6e8768f Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Thu, 15 Feb 2024 16:48:44 +0100 Subject: [PATCH 2/2] fix: add type prop to tests --- src/types/onyx/ReportAction.ts | 2 +- tests/unit/isReportMessageAttachmentTest.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 1b420c7dda54..3ec98fd43178 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -10,7 +10,7 @@ import type {Receipt} from './Transaction'; type Message = { /** The type of the action item fragment. Used to render a corresponding component */ - type?: string; + type: string; /** The text content of the fragment. */ text: string; diff --git a/tests/unit/isReportMessageAttachmentTest.ts b/tests/unit/isReportMessageAttachmentTest.ts index 3014111d5c2c..a20f0646b5dd 100644 --- a/tests/unit/isReportMessageAttachmentTest.ts +++ b/tests/unit/isReportMessageAttachmentTest.ts @@ -6,18 +6,19 @@ describe('isReportMessageAttachment', () => { const message: Message = { text: '[Attachment]', html: '', + type: '', }; expect(isReportMessageAttachment(message)).toBe(true); }); it('returns false if a report action is not attachment', () => { - let message: Message = {text: '[Attachment]', html: '[Attachment]'}; + let message: Message = {text: '[Attachment]', html: '[Attachment]', type: ''}; expect(isReportMessageAttachment(message)).toBe(false); - message = {text: '[Attachment]', html: '[Attachment]'}; + message = {text: '[Attachment]', html: '[Attachment]', type: ''}; expect(isReportMessageAttachment(message)).toBe(false); - message = {text: '[Attachment]', html: '[Attachment]'}; + message = {text: '[Attachment]', html: '[Attachment]', type: ''}; expect(isReportMessageAttachment(message)).toBe(false); }); });