MCPcopy
hub / github.com/tldraw/tldraw / makeTestInstance

Function makeTestInstance

packages/sync-core/src/test/TLSyncRoom.test.ts:1106–1142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1104 })
1105
1106 async function makeTestInstance() {
1107 const server = new TestServer(bookSchema)
1108 const socketPair = new TestSocketPair('test', server)
1109 socketPair.connect()
1110
1111 const flush = async () => {
1112 await Promise.resolve()
1113 while (socketPair.getNeedsFlushing()) {
1114 socketPair.flushClientSentEvents()
1115 socketPair.flushServerSentEvents()
1116 }
1117 }
1118 let onSyncError = vi.fn()
1119 const client = await new Promise<TLSyncClient<Book | Presence>>((resolve, reject) => {
1120 onSyncError = vi.fn(reject)
1121 const client = new TLSyncClient({
1122 store: new Store<Book | Presence, unknown>({
1123 schema: bookSchemaWithoutValidator,
1124 props: {},
1125 }),
1126 socket: socketPair.clientSocket as any,
1127 onLoad: resolve,
1128 onSyncError,
1129 presence: computed('', () => null),
1130 })
1131 disposables.push(() => client.close())
1132 flush()
1133 })
1134
1135 return {
1136 server,
1137 socketPair,
1138 client,
1139 flush,
1140 onSyncError,
1141 }
1142 }
1143
1144 it('[RP2] rejects invalid put operations that create a new document', async () => {
1145 const { client, flush, onSyncError, server } = await makeTestInstance()

Callers 1

TLSyncRoom.test.tsFile · 0.85

Calls 5

connectMethod · 0.95
closeMethod · 0.95
computedFunction · 0.90
flushFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…