@@ -14,7 +14,7 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
1414 describe ( 'block.*' , ( ) => {
1515 describe ( 'block.new' , ( ) => {
1616 test ( 'can create an empty block' , async ( ) => {
17- const { call} = await setup ( ) ;
17+ const { call, stop } = await setup ( ) ;
1818 const id = getId ( ) ;
1919 await call ( 'block.new' , { id, patches : [ ] } ) ;
2020 const { model} = await call ( 'block.get' , { id} ) ;
@@ -27,10 +27,11 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
2727 } ) ;
2828 const model2 = Model . fromBinary ( model . blob ) ;
2929 expect ( model2 . view ( ) ) . toBe ( undefined ) ;
30+ stop ( ) ;
3031 } ) ;
3132
3233 test ( 'can create a block with value' , async ( ) => {
33- const { call} = await setup ( ) ;
34+ const { call, stop } = await setup ( ) ;
3435 const model = Model . withLogicalClock ( ) ;
3536 const id = getId ( ) ;
3637 model . api . root ( {
@@ -66,12 +67,13 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
6667 name : 'Super Woman' ,
6768 age : 26 ,
6869 } ) ;
70+ stop ( ) ;
6971 } ) ;
7072 } ) ;
7173
7274 describe ( 'block.remove' , ( ) => {
7375 test ( 'can remove an existing block' , async ( ) => {
74- const { call} = await setup ( ) ;
76+ const { call, stop } = await setup ( ) ;
7577 const id = getId ( ) ;
7678 await call ( 'block.new' , { id, patches : [ ] } ) ;
7779 const { model} = await call ( 'block.get' , { id} ) ;
@@ -83,12 +85,13 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
8385 } catch ( err : any ) {
8486 expect ( err . errno ) . toBe ( RpcErrorCodes . NOT_FOUND ) ;
8587 }
88+ stop ( ) ;
8689 } ) ;
8790 } ) ;
8891
8992 describe ( 'block.upd' , ( ) => {
9093 test ( 'can edit a document sequentially' , async ( ) => {
91- const { call} = await setup ( ) ;
94+ const { call, stop } = await setup ( ) ;
9295 const id = getId ( ) ;
9396 const model = Model . withLogicalClock ( ) ;
9497 model . api . root ( {
@@ -149,10 +152,11 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
149152 expect ( Model . fromBinary ( block3 . model . blob ) . view ( ) ) . toStrictEqual ( {
150153 text : 'Hello, World!' ,
151154 } ) ;
155+ stop ( ) ;
152156 } ) ;
153157
154158 test ( 'can edit a document concurrently' , async ( ) => {
155- const { call} = await setup ( ) ;
159+ const { call, stop } = await setup ( ) ;
156160 const id = getId ( ) ;
157161
158162 // User 1
@@ -215,10 +219,11 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
215219 const block4 = await call ( 'block.get' , { id} ) ;
216220 const model4 = Model . fromBinary ( block4 . model . blob ) . fork ( ) ;
217221 expect ( model4 . view ( ) ) . not . toStrictEqual ( { text : 'Hell yeah!' } ) ;
222+ stop ( ) ;
218223 } ) ;
219224
220225 test ( 'returns patches that happened concurrently' , async ( ) => {
221- const { call} = await setup ( ) ;
226+ const { call, stop } = await setup ( ) ;
222227 const id = getId ( ) ;
223228
224229 // User 1
@@ -278,13 +283,14 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
278283 expect ( patches [ 2 ] . seq ) . toBe ( 3 ) ;
279284 expect ( patches [ 1 ] . blob ) . toStrictEqual ( patch2 . toBinary ( ) ) ;
280285 expect ( patches [ 2 ] . blob ) . toStrictEqual ( patch3 . toBinary ( ) ) ;
286+ stop ( ) ;
281287 } ) ;
282288 } ) ;
283289
284290 if ( ! params . staticOnly ) {
285291 describe ( 'block.listen' , ( ) => {
286292 test ( 'can listen for block changes' , async ( ) => {
287- const { call, call$} = await setup ( ) ;
293+ const { call, call$, stop } = await setup ( ) ;
288294 const id = getId ( ) ;
289295 await call ( 'block.new' , { id, patches : [ ] } ) ;
290296 await tick ( 11 ) ;
@@ -321,10 +327,11 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
321327 expect ( emits [ 1 ] [ 0 ] ) . toBe ( 'upd' ) ;
322328 expect ( emits [ 1 ] [ 1 ] . patches . length ) . toBe ( 1 ) ;
323329 expect ( emits [ 1 ] [ 1 ] . patches [ 0 ] . seq ) . toBe ( 1 ) ;
330+ stop ( ) ;
324331 } ) ;
325332
326333 test ( 'can subscribe before block is created' , async ( ) => {
327- const { call, call$} = await setup ( ) ;
334+ const { call, call$, stop } = await setup ( ) ;
328335 const emits : any [ ] = [ ] ;
329336 const id = getId ( ) ;
330337 call$ ( 'block.listen' , { id} ) . subscribe ( ( data ) => emits . push ( data ) ) ;
@@ -349,10 +356,11 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
349356 expect ( emits [ 0 ] [ 1 ] . patches . length ) . toBe ( 1 ) ;
350357 expect ( emits [ 0 ] [ 1 ] . patches [ 0 ] . seq ) . toBe ( 0 ) ;
351358 expect ( emits [ 0 ] [ 1 ] . patches [ 0 ] . blob ) . toStrictEqual ( patch1 . toBinary ( ) ) ;
359+ stop ( ) ;
352360 } ) ;
353361
354362 test ( 'can receive deletion events' , async ( ) => {
355- const { call, call$} = await setup ( ) ;
363+ const { call, call$, stop } = await setup ( ) ;
356364 const emits : any [ ] = [ ] ;
357365 const id = getId ( ) ;
358366 call$ ( 'block.listen' , { id} ) . subscribe ( ( data ) => {
@@ -365,13 +373,14 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
365373 await call ( 'block.del' , { id} ) ;
366374 await until ( ( ) => emits . length === 2 ) ;
367375 expect ( emits [ 1 ] [ 0 ] ) . toBe ( 'del' ) ;
376+ stop ( ) ;
368377 } ) ;
369378 } ) ;
370379 }
371380
372381 describe ( 'block.scan' , ( ) => {
373382 test ( 'can retrieve change history' , async ( ) => {
374- const { call} = await setup ( ) ;
383+ const { call, stop } = await setup ( ) ;
375384 const id = getId ( ) ;
376385 const model = Model . withLogicalClock ( ) ;
377386 model . api . root ( {
@@ -428,12 +437,13 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
428437 } ,
429438 ] ,
430439 } ) ;
440+ stop ( ) ;
431441 } ) ;
432442 } ) ;
433443
434444 describe ( 'block.get' , ( ) => {
435445 test ( 'returns whole history when block is loaded' , async ( ) => {
436- const { call} = await setup ( ) ;
446+ const { call, stop } = await setup ( ) ;
437447 const id = getId ( ) ;
438448 const model = Model . withLogicalClock ( ) ;
439449 model . api . root ( {
@@ -496,6 +506,7 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
496506 } ,
497507 ] ,
498508 } ) ;
509+ stop ( ) ;
499510 } ) ;
500511 } ) ;
501512 } ) ;
0 commit comments