Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Sep 7, 2021
1 parent f6445f4 commit 635abd9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/__tests__/Chat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/components/Input/__tests__/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
})

Expand Down Expand Up @@ -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')
})

Expand All @@ -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', '')
})

Expand All @@ -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)
})

Expand All @@ -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', '')
})

Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export namespace MessageType {

export interface PartialCustom extends Base {
metadata?: Record<string, any>
type: 'custom'
}

export interface Custom extends Base, PartialCustom {
Expand All @@ -71,6 +72,7 @@ export namespace MessageType {
mimeType?: string
name: string
size: number
type: 'file'
uri: string
}

Expand All @@ -83,6 +85,7 @@ export namespace MessageType {
metadata?: Record<string, any>
name: string
size: number
type: 'image'
uri: string
width?: number
}
Expand All @@ -95,6 +98,7 @@ export namespace MessageType {
metadata?: Record<string, any>
previewData?: PreviewData
text: string
type: 'text'
}

export interface Text extends Base, PartialText {
Expand Down

0 comments on commit 635abd9

Please sign in to comment.