@@ -48,7 +48,9 @@ describe('Threads 2.0', () => {
4848 beforeEach ( ( ) => {
4949 client = new StreamChat ( 'apiKey' ) ;
5050 client . _setUser ( { id : TEST_USER_ID } ) ;
51- channelResponse = generateChannel ( { channel : { id : uuidv4 ( ) , name : 'Test channel' } } ) . channel as ChannelResponse ;
51+ channelResponse = generateChannel ( {
52+ channel : { id : uuidv4 ( ) , name : 'Test channel' , members : [ ] } ,
53+ } ) . channel as ChannelResponse ;
5254 channel = client . channel ( channelResponse . type , channelResponse . id ) ;
5355 parentMessageResponse = generateMsg ( ) as MessageResponse ;
5456 threadManager = new ThreadManager ( { client } ) ;
@@ -57,12 +59,16 @@ describe('Threads 2.0', () => {
5759 describe ( 'Thread' , ( ) => {
5860 it ( 'initializes properly' , ( ) => {
5961 const threadResponse = generateThreadResponse ( channelResponse , parentMessageResponse ) ;
62+ // mimic pre-cached channel with existing members
63+ channel . _hydrateMembers ( { members : [ { user : { id : TEST_USER_ID } } ] } ) ;
6064 const thread = new Thread ( { client, threadData : threadResponse } ) ;
6165 const state = thread . state . getLatestValue ( ) ;
6266
67+ expect ( threadResponse . channel . members ) . to . have . lengthOf ( 0 ) ;
6368 expect ( threadResponse . read ) . to . have . lengthOf ( 0 ) ;
6469 expect ( state . read ) . to . have . keys ( [ TEST_USER_ID ] ) ;
6570
71+ expect ( thread . channel . state . members ) . to . have . keys ( [ TEST_USER_ID ] ) ;
6672 expect ( thread . id ) . to . equal ( parentMessageResponse . id ) ;
6773 expect ( thread . channel . data ?. name ) . to . equal ( channelResponse . name ) ;
6874 } ) ;
0 commit comments