File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed
components/MessageList/__tests__ Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,10 @@ describe('MessageList', () => {
240240 fireEvent . scroll ( getByTestId ( 'message-flat-list' ) , eventDataUp ) ;
241241
242242 act ( ( ) => {
243- const newMessage = generateMessage ( { user : user2 } ) ;
243+ const newMessage = generateMessage ( {
244+ timestamp : new Date ( ) ,
245+ user : user2 ,
246+ } ) ;
244247 dispatchMessageNewEvent ( chatClient , newMessage , mockedChannel . channel ) ;
245248 } ) ;
246249
Original file line number Diff line number Diff line change @@ -2,17 +2,23 @@ import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
22
33import { generateUser } from './user' ;
44
5- export const generateMessage = ( options ) => ( {
6- attachments : [ ] ,
7- created_at : new Date ( ) . toString ( ) ,
8- html : '<p>regular</p>' ,
9- id : uuidv4 ( ) ,
10- text : uuidv4 ( ) ,
11- type : 'regular' ,
12- updated_at : new Date ( ) . toString ( ) ,
13- user : generateUser ( ) ,
14- ...options ,
15- } ) ;
5+ export const generateMessage = ( options = { } ) => {
6+ const timestamp =
7+ options . timestamp ||
8+ new Date ( new Date ( ) . getTime ( ) - Math . floor ( Math . random ( ) * 100000 ) ) ;
9+
10+ return {
11+ attachments : [ ] ,
12+ created_at : timestamp . toString ( ) ,
13+ html : '<p>regular</p>' ,
14+ id : uuidv4 ( ) ,
15+ text : uuidv4 ( ) ,
16+ type : 'regular' ,
17+ updated_at : timestamp . toString ( ) ,
18+ user : generateUser ( ) ,
19+ ...options ,
20+ } ;
21+ } ;
1622
1723const StreamReactNativeNamespace = '9b244ee4-7d69-4d7b-ae23-cf89e9f7b035' ;
1824export const generateStaticMessage = ( seed , options , date ) =>
You can’t perform that action at this time.
0 commit comments