From 635abd9814a1aeb8c8f19255dbb603638eb61b5b Mon Sep 17 00:00:00 2001 From: Alex Demchenko Date: Tue, 7 Sep 2021 08:47:28 +0200 Subject: [PATCH] Update types --- package.json | 2 +- src/components/Chat/__tests__/Chat.test.tsx | 2 +- src/components/Input/Input.tsx | 2 +- src/components/Input/__tests__/Input.test.tsx | 13 ++++++++----- src/types.ts | 4 ++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 831177f..f6a1312 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@flyerhq/react-native-chat-ui", - "version": "1.3.1", + "version": "1.3.2", "description": "Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS.", "homepage": "https://flyer.chat", "main": "lib/index.js", diff --git a/src/components/Chat/__tests__/Chat.test.tsx b/src/components/Chat/__tests__/Chat.test.tsx index 18a4b12..98ca0a8 100644 --- a/src/components/Chat/__tests__/Chat.test.tsx +++ b/src/components/Chat/__tests__/Chat.test.tsx @@ -63,7 +63,7 @@ describe('chat', () => { ) const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: 'text' }) + expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' }) }) it('opens file on a file message tap', () => { diff --git a/src/components/Input/Input.tsx b/src/components/Input/Input.tsx index cc72257..c23da2e 100644 --- a/src/components/Input/Input.tsx +++ b/src/components/Input/Input.tsx @@ -72,7 +72,7 @@ export const Input = ({ // Additional check for the keyboard input. /* istanbul ignore next */ if (trimmedValue) { - onSendPress({ text: trimmedValue }) + onSendPress({ text: trimmedValue, type: 'text' }) setText('') } } diff --git a/src/components/Input/__tests__/Input.test.tsx b/src/components/Input/__tests__/Input.test.tsx index 611fd65..081a348 100644 --- a/src/components/Input/__tests__/Input.test.tsx +++ b/src/components/Input/__tests__/Input.test.tsx @@ -28,7 +28,7 @@ describe('input', () => { fireEvent.changeText(textInput, 'text') const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: 'text' }) + expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' }) expect(textInput.props).toHaveProperty('value', '') }) @@ -66,7 +66,7 @@ describe('input', () => { fireEvent.changeText(textInput, 'text') const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: 'text' }) + expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' }) expect(textInput.props).toHaveProperty('value', 'text') }) @@ -90,7 +90,7 @@ describe('input', () => { fireEvent.changeText(textInput, 'text') const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: 'text' }) + expect(onSendPress).toHaveBeenCalledWith({ text: 'text', type: 'text' }) expect(textInput.props).toHaveProperty('value', '') }) @@ -114,7 +114,7 @@ describe('input', () => { fireEvent.changeText(textInput, 'text') const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: value }) + expect(onSendPress).toHaveBeenCalledWith({ text: value, type: 'text' }) expect(textInput.props).toHaveProperty('value', value) }) @@ -137,7 +137,10 @@ describe('input', () => { const textInput = getByPlaceholderText(l10n.en.inputPlaceholder) const button = getByLabelText(l10n.en.sendButtonAccessibilityLabel) fireEvent.press(button) - expect(onSendPress).toHaveBeenCalledWith({ text: defaultValue }) + expect(onSendPress).toHaveBeenCalledWith({ + text: defaultValue, + type: 'text', + }) expect(textInput.props).toHaveProperty('value', '') }) diff --git a/src/types.ts b/src/types.ts index 16e8822..4b865a6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -60,6 +60,7 @@ export namespace MessageType { export interface PartialCustom extends Base { metadata?: Record + type: 'custom' } export interface Custom extends Base, PartialCustom { @@ -71,6 +72,7 @@ export namespace MessageType { mimeType?: string name: string size: number + type: 'file' uri: string } @@ -83,6 +85,7 @@ export namespace MessageType { metadata?: Record name: string size: number + type: 'image' uri: string width?: number } @@ -95,6 +98,7 @@ export namespace MessageType { metadata?: Record previewData?: PreviewData text: string + type: 'text' } export interface Text extends Base, PartialText {