Allow overriding WebSocket implementation and add flaky version for testing

This commit is contained in:
Andras Schmelczer 2025-04-07 23:13:45 +01:00
parent 74a8060246
commit 3ec6bd4d5b
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
8 changed files with 162 additions and 73 deletions

View file

@ -56,7 +56,8 @@ export class SyncClient {
public static async create({
fs,
persistence,
fetch = globalThis.fetch,
fetch,
webSocket,
nativeLineEndings = "\n"
}: {
fs: FileSystemOperations;
@ -67,6 +68,7 @@ export class SyncClient {
}>
>;
fetch?: typeof globalThis.fetch;
webSocket?: typeof globalThis.WebSocket;
nativeLineEndings?: string;
}): Promise<SyncClient> {
const logger = new Logger();
@ -113,9 +115,10 @@ export class SyncClient {
deviceId,
connectionStatus,
settings,
logger
logger,
fetch
);
syncService.fetchImplementation = fetch;
const fileOperations = new FileOperations(
logger,
database,
@ -137,7 +140,8 @@ export class SyncClient {
settings,
syncService,
fileOperations,
unrestrictedSyncer
unrestrictedSyncer,
webSocket
);
const client = new SyncClient(