@@ -81,29 +81,35 @@ describe("CallMembership", () => {
8181 } ) ;
8282
8383 it ( "returns preferred foci" , ( ) => {
84- const mockFocus = { type : "this_is_a_mock_focus " } ;
84+ const mockFocus = { type : "livekit" , livekit_service_url : "https://example.org " } ;
8585 const fakeEvent = makeMockEvent ( 0 , { ...membershipTemplate , foci_preferred : [ mockFocus ] } ) ;
8686 const membership = new CallMembership ( fakeEvent ) ;
87- expect ( membership . transports ) . toEqual ( [ mockFocus ] ) ;
87+ expect ( membership . transports . length ) . toEqual ( 1 ) ;
88+ expect ( membership . transports [ 0 ] ) . toEqual ( expect . objectContaining ( { type : "livekit" } ) ) ;
8889 } ) ;
8990
9091 describe ( "getTransport" , ( ) => {
91- const mockFocus = { type : "this_is_a_mock_focus " } ;
92+ const mockFocus = { type : "livekit" , livekit_service_url : "https://example.org " } ;
9293 const oldestMembership = new CallMembership ( makeMockEvent ( 0 , membershipTemplate ) ) ;
9394 it ( "gets the correct active transport with oldest_membership" , ( ) => {
9495 const membership = new CallMembership (
9596 makeMockEvent ( 0 , {
9697 ...membershipTemplate ,
98+ // The list of foci_preferred provided by the homeserver. (in the test example we just provide one)
99+ // The oldest member logic will use the first item in this list.
100+ // The multi-sfu logic will (theoretically) also use all the items in the list at once
101+ // (currently the js-sdk sets it to only one item in multi-sfu mode).
97102 foci_preferred : [ mockFocus ] ,
98103 focus_active : { type : "livekit" , focus_selection : "oldest_membership" } ,
99104 } ) ,
100105 ) ;
101106
102107 // if we are the oldest member we use our focus.
103- expect ( membership . getTransport ( membership ) ) . toStrictEqual ( mockFocus ) ;
108+ expect ( membership . getTransport ( membership ) ) . toEqual ( expect . objectContaining ( { type : "livekit" } ) ) ;
109+ expect ( membership . transports [ 0 ] ) . toEqual ( expect . objectContaining ( { type : "livekit" } ) ) ;
104110
105111 // If there is an older member we use its focus.
106- expect ( membership . getTransport ( oldestMembership ) ) . toBe ( membershipTemplate . foci_preferred [ 0 ] ) ;
112+ expect ( membership . getTransport ( oldestMembership ) ) . toEqual ( expect . objectContaining ( { type : "livekit" } ) ) ;
107113 } ) ;
108114
109115 it ( "gets the correct active transport with multi_sfu" , ( ) => {
@@ -115,7 +121,7 @@ describe("CallMembership", () => {
115121 } ) ,
116122 ) ;
117123
118- // if we are the oldest member we use our focus.
124+ // We use our focus.
119125 expect ( membership . getTransport ( membership ) ) . toStrictEqual ( mockFocus ) ;
120126
121127 // If there is an older member we still use our own focus in multi sfu.
@@ -130,7 +136,6 @@ describe("CallMembership", () => {
130136 } ) ,
131137 ) ;
132138
133- // if we are the oldest member we use our focus.
134139 expect ( membership . getTransport ( membership ) ) . toBeUndefined ( ) ;
135140 } ) ;
136141 } ) ;
0 commit comments