File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
src/mock-builders/generator Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 11import { nanoid } from 'nanoid' ;
2+ import type { ChannelConfigWithInfo , ChannelResponse } from 'stream-chat' ;
23
3- export const generateChannel = ( options = { channel : { } } ) => {
4+ export const generateChannel = (
5+ options : {
6+ channel ?: Partial < ChannelResponse > ;
7+ config ?: Partial < ChannelConfigWithInfo > ;
8+ } = { channel : { } , config : { } } ,
9+ ) => {
410 const { channel : optionsChannel , config, ...optionsBesidesChannel } = options ;
511 const id = optionsChannel ?. id ?? nanoid ( ) ;
612 const type = optionsChannel ?. type ?? 'messaging' ;
@@ -43,7 +49,7 @@ export const generateChannel = (options = { channel: {} }) => {
4349 uploads : true ,
4450 url_enrichment : true ,
4551 ...config ,
46- } ,
52+ } as ChannelConfigWithInfo ,
4753
4854 created_at : '2020-04-28T11:20:48.578147Z' ,
4955
@@ -56,11 +62,12 @@ export const generateChannel = (options = { channel: {} }) => {
5662 role : 'user' ,
5763 updated_at : '2020-04-28T11:21:08.357468Z' ,
5864 } ,
65+ disabled : false ,
5966 frozen : false ,
6067 id,
6168 type,
6269 updated_at : '2020-04-28T11:20:48.578147Z' ,
6370 ...restOptionsChannel ,
64- } ,
71+ } as ChannelResponse ,
6572 } ;
6673} ;
Original file line number Diff line number Diff line change 11import type { ReminderResponse } from 'stream-chat' ;
2+ import { generateChannel } from './channel' ;
23
34const baseData = {
4- channel_cid : 'channel_cid ' ,
5+ channel_cid : 'messaging:id ' ,
56 message_id : 'message_id' ,
67 user_id : 'user_id' ,
78} as const ;
@@ -16,6 +17,7 @@ export const generateReminderResponse = ({
1617 const created_at = new Date ( ) . toISOString ( ) ;
1718 const basePayload : ReminderResponse = {
1819 ...baseData ,
20+ channel : generateChannel ( { channel : { cid : baseData . channel_cid } } ) . channel ,
1921 created_at,
2022 message : { id : baseData . message_id , type : 'regular' } ,
2123 updated_at : created_at ,
You can’t perform that action at this time.
0 commit comments