1- import * as t from "lib0/testing " ;
1+ import assert , { deepEqual } from "node:assert " ;
22import * as prng from "lib0/prng" ;
33import * as encoding from "lib0/encoding" ;
44import * as decoding from "lib0/decoding" ;
@@ -75,14 +75,14 @@ export class TestYOctoInstance extends Y.Doc {
7575 testConnector . allConns . add ( this ) ;
7676 this . updates = [ ] ;
7777 // set up observe on local model
78- this . onUpdate ( ( update ) => {
79- if ( origin !== testConnector ) {
80- const encoder = encoding . createEncoder ( ) ;
81- syncProtocol . writeUpdate ( encoder , update ) ;
82- broadcastMessage ( this , encoding . toUint8Array ( encoder ) ) ;
83- }
84- this . updates . push ( update ) ;
85- } ) ;
78+ // this.onUpdate((update) => {
79+ // // if (origin !== testConnector) {
80+ // // const encoder = encoding.createEncoder();
81+ // // syncProtocol.writeUpdate(encoder, update);
82+ // // broadcastMessage(this, encoding.toUint8Array(encoder));
83+ // / / }
84+ // this.updates.push(update);
85+ // });
8686 this . connect ( ) ;
8787 }
8888
@@ -154,6 +154,7 @@ export class TestConnector {
154154 * If this function was unable to flush a message, because there are no more messages to flush, it returns false. true otherwise.
155155 */
156156 flushRandomMessage ( ) : boolean {
157+ return false ;
157158 const gen = this . prng ;
158159 const conns = Array . from ( this . onlineConns ) . filter (
159160 ( conn ) => conn . receiving . size > 0 ,
@@ -201,13 +202,11 @@ export class TestConnector {
201202 }
202203
203204 reconnectAll ( ) {
204- this . allConns . forEach ( ( conn : { connect : ( ) => any } ) => conn . connect ( ) ) ;
205+ this . allConns . forEach ( ( conn ) => conn . connect ( ) ) ;
205206 }
206207
207208 disconnectAll ( ) {
208- this . allConns . forEach ( ( conn : { disconnect : ( ) => any } ) =>
209- conn . disconnect ( ) ,
210- ) ;
209+ this . allConns . forEach ( ( conn ) => conn . disconnect ( ) ) ;
211210 }
212211
213212 syncAll ( ) {
@@ -330,32 +329,32 @@ export const compare = (users: TestYOctoInstance[]) => {
330329 // t.assert(u.store.pendingStructs === null);
331330 // }
332331 // Test Array iterator
333- t . compare (
332+ deepEqual (
334333 users [ 0 ] . getOrCreateArray ( "array" ) . toArray ( ) ,
335334 Array . from ( users [ 0 ] . getOrCreateArray ( "array" ) . iter ( ) ) ,
336335 ) ;
337336 // Test Map iterator
338337 const ymapkeys : any [ ] = Array . from ( users [ 0 ] . getOrCreateMap ( "map" ) . keys ( ) ) ;
339- t . assert ( ymapkeys . length === Object . keys ( userMapValues [ 0 ] ) . length ) ;
338+ assert ( ymapkeys . length === Object . keys ( userMapValues [ 0 ] ) . length ) ;
340339 ymapkeys . forEach ( ( key ) =>
341- t . assert ( object . hasProperty ( userMapValues [ 0 ] , key ) ) ,
340+ assert ( object . hasProperty ( userMapValues [ 0 ] , key ) ) ,
342341 ) ;
343342
344343 const mapRes : Record < string , any > = { } ;
345344 for ( const [ k , v ] of users [ 0 ] . getOrCreateMap ( "map" ) . entries ( ) ) {
346345 mapRes [ k ] = Y . isAbstractType ( v ) ? v . toJSON ( ) : v ;
347346 }
348- t . compare ( userMapValues [ 0 ] , mapRes ) ;
347+ deepEqual ( userMapValues [ 0 ] , mapRes ) ;
349348 // Compare all users
350349 for ( let i = 0 ; i < users . length - 1 ; i ++ ) {
351- t . compare (
350+ deepEqual (
352351 userArrayValues [ i ] . length ,
353352 users [ i ] . getOrCreateArray ( "array" ) . length ,
354353 ) ;
355- t . compare ( userArrayValues [ i ] , userArrayValues [ i + 1 ] ) ;
356- t . compare ( userMapValues [ i ] , userMapValues [ i + 1 ] ) ;
357- // t.compare (userXmlValues[i], userXmlValues[i + 1]);
358- // t.compare (
354+ deepEqual ( userArrayValues [ i ] , userArrayValues [ i + 1 ] ) ;
355+ deepEqual ( userMapValues [ i ] , userMapValues [ i + 1 ] ) ;
356+ // deepEqual (userXmlValues[i], userXmlValues[i + 1]);
357+ // deepEqual (
359358 // userTextValues[i]
360359 // .map(
361360 // /** @param {any } a */ (a: { insert: any }) =>
@@ -364,26 +363,26 @@ export const compare = (users: TestYOctoInstance[]) => {
364363 // .join("").length,
365364 // users[i].getOrCreateText("text").length,
366365 // );
367- // t.compare (
366+ // deepEqual (
368367 // userTextValues[i],
369368 // userTextValues[i + 1],
370369 // "",
371370 // (_constructor, a, b) => {
372371 // if (Y.isAbstractType(a)) {
373- // t.compare (a.toJSON(), b.toJSON());
372+ // deepEqual (a.toJSON(), b.toJSON());
374373 // } else if (a !== b) {
375374 // t.fail("Deltas dont match");
376375 // }
377376 // return true;
378377 // },
379378 // );
380- t . compare ( Y . encodeStateVector ( users [ i ] ) , Y . encodeStateVector ( users [ i + 1 ] ) ) ;
379+ deepEqual ( Y . encodeStateVector ( users [ i ] ) , Y . encodeStateVector ( users [ i + 1 ] ) ) ;
381380 Y . equalDeleteSets (
382381 Y . createDeleteSetFromStructStore ( users [ i ] . store ) ,
383382 Y . createDeleteSetFromStructStore ( users [ i + 1 ] . store ) ,
384383 ) ;
385384 Y . compareStructStores ( users [ i ] . store , users [ i + 1 ] . store ) ;
386- t . compare (
385+ deepEqual (
387386 Y . encodeSnapshot ( Y . snapshot ( users [ i ] ) ) ,
388387 Y . encodeSnapshot ( Y . snapshot ( users [ i + 1 ] ) ) ,
389388 ) ;
0 commit comments