-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit test for mobile draft #8363
base: main
Are you sure you want to change the base?
Changes from all commits
63b313f
11e758e
d72a19f
572d65b
d5389b8
ae55bde
afbe59d
6c99a7c
9fcbf84
d688908
324aa16
65b6edd
272c468
1fa189a
ba3ee8d
554123f
e629247
f8bcead
6577c6e
d331d46
62d0bbb
5308824
611cff0
aac1f38
8c153d6
112048a
2589127
a70b165
6f56a41
e140826
a85a1a4
c72c14d
f5b884a
cffb22b
b9c48d5
424c773
6f054ae
15e6bc3
faabf4e
9b130b6
c595c3d
b167354
eee6c26
47ac4fe
a842910
b26aa59
3d16827
5d7bc78
e667dd7
f152788
aa1ad72
f2e2e47
cd93248
8965394
8c8e6f6
be07659
ab7ce3a
2b5a671
22f1528
a542590
ea131a8
1ca7ddb
8a1952e
2941ab1
07ec62c
80681bd
9ea0914
ba7fb70
8d427db
2954843
d4c988b
2fca19c
1d7b0be
1261a4b
507cdeb
0a303e1
3d426c0
83d4c21
f0dd52d
c75c9af
4f7c2cb
da2cbdf
a5e683d
b2960c5
949089f
9abea9f
74d815d
abc7f4c
4cfef6b
fd0d5ff
89b6c3c
3556a0e
2ebbf2a
1c4661b
b23bd9e
10b54b3
976c9eb
c6478c3
0ee8296
a45371e
6a4ad10
34a142e
10ec08b
96be469
76c6b31
37284c7
3f3928b
b3b17b4
b42ce63
83fda81
95c1549
42811c9
6ddf0d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,190 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// See LICENSE.txt for license information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
import React from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
import CompassIcon from '@components/compass_icon'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import FormattedText from '@components/formatted_text'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import {General} from '@constants'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import {renderWithEverything} from '@test/intl-test-helper'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import TestHelper from '@test/test_helper'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
import Draft from './draft'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
import type {Database} from '@nozbe/watermelondb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import type ChannelModel from '@typings/database/models/servers/channel'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import type DraftModel from '@typings/database/models/servers/draft'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
jest.mock('@components/formatted_text', () => jest.fn(() => null)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
jest.mock('@components/formatted_time', () => jest.fn(() => null)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
jest.mock('@components/compass_icon', () => jest.fn(() => null)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
describe('Draft', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let database: Database; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
beforeAll(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const server = await TestHelper.setupServerDatabase(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
database = server.database; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should render the draft with channel info and draft message', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel: {type: General.OPEN_CHANNEL, displayName: 'Direct Message Channel'} as ChannelModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location: 'channel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
updateAt: 1633024800000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
message: 'Hello, World!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channelId: 'channel_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
rootId: '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
files: [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
metadata: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} as unknown as DraftModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth: 100, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const wrapper = renderWithEverything( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<Draft | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel={props.channel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location={props.location} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft={props.draft} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth={props.layoutWidth} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled={props.isPostPriorityEnabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
, {database}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
const {getByText} = wrapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+44
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can destructure directly or perhaps use wrapper.getByText?
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(FormattedText).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.objectContaining({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
id: 'channel_info.draft_in_channel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
defaultMessage: 'In:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.anything(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(CompassIcon).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.objectContaining({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: 'globe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.anything(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(getByText('Hello, World!')).toBeTruthy(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is having snapshot adding any more value? |
||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should match the file count', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel: {type: General.OPEN_CHANNEL, displayName: 'Direct Message Channel'} as ChannelModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location: 'channel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
updateAt: 1633024800000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
message: 'Hello, World!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channelId: 'channel_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
rootId: '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
files: [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
has_preview_image: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
height: 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: 'file1.txt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
extension: 'txt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
size: 64, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
has_preview_image: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
height: 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: 'file2.pdf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
extension: 'txt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
size: 64, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
metadata: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} as unknown as DraftModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth: 100, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const wrapper = renderWithEverything( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<Draft | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel={props.channel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location={props.location} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft={props.draft} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth={props.layoutWidth} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled={props.isPostPriorityEnabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
, {database}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const {getAllByTestId} = wrapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(getAllByTestId('file_attachment')).toHaveLength(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+101
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question throughout, how would the snapshot help understand that there are two files? |
||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should render the draft with channel info and draft message for a thread', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel: {type: General.OPEN_CHANNEL, displayName: 'Direct Message Channel'} as ChannelModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location: 'thread', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
updateAt: 1633024800000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
message: 'Hello, World!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channelId: 'channel_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
rootId: 'root_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
files: [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
metadata: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} as unknown as DraftModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth: 100, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const wrapper = renderWithEverything( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<Draft | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel={props.channel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location={props.location} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft={props.draft} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth={props.layoutWidth} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled={props.isPostPriorityEnabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
, {database}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
const {getByText} = wrapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(FormattedText).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.objectContaining({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
id: 'channel_info.thread_in', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
defaultMessage: 'Thread in:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.anything(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(CompassIcon).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.objectContaining({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
name: 'globe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect.anything(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(getByText('Hello, World!')).toBeTruthy(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should render the draft with post priority', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel: {type: General.OPEN_CHANNEL, displayName: 'Direct Message Channel'} as ChannelModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location: 'thread', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
updateAt: 1633024800000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
message: 'Hello, World!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channelId: 'channel_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
rootId: 'root_id', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
files: [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
metadata: {priority: {priority: 'important', requested_ack: false}}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} as unknown as DraftModel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth: 100, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const wrapper = renderWithEverything( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<Draft | ||||||||||||||||||||||||||||||||||||||||||||||||||||
channel={props.channel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
location={props.location} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
draft={props.draft} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
layoutWidth={props.layoutWidth} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
isPostPriorityEnabled={props.isPostPriorityEnabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
, {database}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
const {getByText} = wrapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(getByText('IMPORTANT')).toBeTruthy(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Draft Message should match snapshot 1`] = ` | ||
<View | ||
style={ | ||
{ | ||
"maxHeight": 721, | ||
} | ||
} | ||
testID="draft_message" | ||
> | ||
<RCTScrollView | ||
keyboardShouldPersistTaps="always" | ||
scrollEnabled={false} | ||
showsHorizontalScrollIndicator={false} | ||
showsVerticalScrollIndicator={false} | ||
> | ||
<View> | ||
<View | ||
onLayout={[Function]} | ||
style={ | ||
[ | ||
{ | ||
"width": "100%", | ||
}, | ||
] | ||
} | ||
> | ||
<View | ||
style={ | ||
[ | ||
{ | ||
"alignItems": "flex-start", | ||
"flexDirection": "row", | ||
"flexWrap": "wrap", | ||
}, | ||
] | ||
} | ||
testID="markdown_paragraph" | ||
> | ||
<Text> | ||
<Text | ||
selectable={false} | ||
style={ | ||
{ | ||
"color": "#3f4350", | ||
"fontFamily": "OpenSans", | ||
"fontSize": 16, | ||
"fontWeight": "400", | ||
"lineHeight": 24, | ||
} | ||
} | ||
testID="markdown_text" | ||
> | ||
Hello, World! | ||
</Text> | ||
</Text> | ||
</View> | ||
</View> | ||
</View> | ||
</RCTScrollView> | ||
</View> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Draft Post should match the snapshot 1`] = ` | ||
<View | ||
style={ | ||
{ | ||
"marginTop": 12, | ||
} | ||
} | ||
testID="draft_post_with_message_and_file" | ||
> | ||
<View | ||
style={ | ||
{ | ||
"maxHeight": 721, | ||
} | ||
} | ||
testID="draft_message" | ||
> | ||
<RCTScrollView | ||
keyboardShouldPersistTaps="always" | ||
scrollEnabled={false} | ||
showsHorizontalScrollIndicator={false} | ||
showsVerticalScrollIndicator={false} | ||
> | ||
<View> | ||
<View | ||
onLayout={[Function]} | ||
style={ | ||
[ | ||
{ | ||
"width": "100%", | ||
}, | ||
] | ||
} | ||
> | ||
<View | ||
style={ | ||
[ | ||
{ | ||
"alignItems": "flex-start", | ||
"flexDirection": "row", | ||
"flexWrap": "wrap", | ||
}, | ||
] | ||
} | ||
testID="markdown_paragraph" | ||
> | ||
<Text> | ||
<Text | ||
selectable={false} | ||
style={ | ||
{ | ||
"color": "#3f4350", | ||
"fontFamily": "OpenSans", | ||
"fontSize": 16, | ||
"fontWeight": "400", | ||
"lineHeight": 24, | ||
} | ||
} | ||
testID="markdown_text" | ||
> | ||
Hello, World! | ||
</Text> | ||
</Text> | ||
</View> | ||
</View> | ||
</View> | ||
</RCTScrollView> | ||
</View> | ||
</View> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
|
||
import {renderWithEverything} from '@test/intl-test-helper'; | ||
import TestHelper from '@test/test_helper'; | ||
|
||
import DraftMessage from './draft_message'; | ||
|
||
import type {Database} from '@nozbe/watermelondb'; | ||
import type DraftModel from '@typings/database/models/servers/draft'; | ||
|
||
describe('Draft Message', () => { | ||
let database: Database; | ||
|
||
beforeAll(async () => { | ||
const server = await TestHelper.setupServerDatabase(); | ||
database = server.database; | ||
}); | ||
it('should render the message', () => { | ||
const props = { | ||
draft: { | ||
updateAt: 1633024800000, | ||
message: 'Hello, World!', | ||
channelId: 'channel_id', | ||
rootId: '', | ||
files: [], | ||
metadata: {}, | ||
} as unknown as DraftModel, | ||
layoutWidth: 100, | ||
location: 'draft', | ||
}; | ||
const {getByText} = renderWithEverything( | ||
<DraftMessage {...props}/>, {database}, | ||
); | ||
expect(getByText('Hello, World!')).toBeTruthy(); | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
const props = { | ||
draft: { | ||
updateAt: 1633024800000, | ||
message: 'Hello, World!', | ||
channelId: 'channel_id', | ||
rootId: '', | ||
files: [], | ||
metadata: {}, | ||
} as unknown as DraftModel, | ||
layoutWidth: 100, | ||
location: 'draft', | ||
}; | ||
const wrapper = renderWithEverything( | ||
<DraftMessage {...props}/>, {database}, | ||
); | ||
|
||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any strong reason to mock these three components?