@@ -3,13 +3,12 @@ import {JsonPatchStore} from 'json-joy/lib/json-crdt/json-patch';
33import { setup } from './setup' ;
44import { until } from 'thingies/lib/until' ;
55import { EditSessionFactory } from '../EditSessionFactory' ;
6- import { tick } from 'thingies' ;
76
87describe ( 'JSON Patch interface' , ( ) => {
98 test ( 'can edit two sessions in the same tab' , async ( ) => {
109 const kit = await setup ( ) ;
1110 const schema = s . obj ( { foo : s . con ( 'bar' ) } ) ;
12- const session1 = kit . sessions . make ( { id : kit . blockId , schema, session : 1 } ) ;
11+ const { session : session1 } = kit . sessions . make ( { id : kit . blockId , schema, session : 1 } ) ;
1312 const session2 = await kit . sessions . load ( { id : kit . blockId , make : { schema, session : 2 } } ) ;
1413 const jp1 = new JsonPatchStore ( session1 . model ) ;
1514 const jp2 = new JsonPatchStore ( session2 . model ) ;
@@ -46,10 +45,10 @@ describe('JSON Patch interface', () => {
4645 await kit . stop ( ) ;
4746 } ) ;
4847
49- test . only ( 'can edit two sessions in different tabs' , async ( ) => {
48+ test ( 'can edit two sessions in different tabs' , async ( ) => {
5049 const kit = await setup ( ) ;
5150 const schema = s . obj ( { foo : s . con ( 'bar' ) } ) ;
52- const session1 = kit . sessions . make ( { id : kit . blockId , schema, session : 1 } ) ;
51+ const { session : session1 } = kit . sessions . make ( { id : kit . blockId , schema, session : 1 } ) ;
5352 const local2 = await kit . createLocal ( ) ;
5453 const sessions2 = new EditSessionFactory ( {
5554 sid : local2 . sid ,
@@ -72,19 +71,18 @@ describe('JSON Patch interface', () => {
7271 } ;
7372 await assertView ( { foo : 'bar' } ) ;
7473 jp2 . update ( { op : 'add' , path : '/tags' , value : [ 'tag1' , 'tag2' ] } ) ;
75- await tick ( 123 ) ;
76- // await assertView({foo: 'bar', tags: ['tag1', 'tag2']});
77- // jp1.update({op: 'add', path: '/a', value: {b: 'c'}});
78- // await assertView({foo: 'bar', tags: ['tag1', 'tag2'], a: {b: 'c'}});
79- // jp1.update([
80- // {op: 'str_ins', path: '/a/b', pos: 1, str: 'd'},
81- // {op: 'add', path: '/a/x', value: 'y'},
82- // ]);
83- // jp2.update([
84- // {op: 'remove', path: ['foo']},
85- // {op: 'add', path: '/a/y', value: 'x'},
86- // ]);
87- // await assertView({tags: ['tag1', 'tag2'], a: {b: 'cd', x: 'y', y: 'x'}});
74+ await assertView ( { foo : 'bar' , tags : [ 'tag1' , 'tag2' ] } ) ;
75+ jp1 . update ( { op : 'add' , path : '/a' , value : { b : 'c' } } ) ;
76+ await assertView ( { foo : 'bar' , tags : [ 'tag1' , 'tag2' ] , a : { b : 'c' } } ) ;
77+ jp1 . update ( [
78+ { op : 'str_ins' , path : '/a/b' , pos : 1 , str : 'd' } ,
79+ { op : 'add' , path : '/a/x' , value : 'y' } ,
80+ ] ) ;
81+ jp2 . update ( [
82+ { op : 'remove' , path : [ 'foo' ] } ,
83+ { op : 'add' , path : '/a/y' , value : 'x' } ,
84+ ] ) ;
85+ await assertView ( { tags : [ 'tag1' , 'tag2' ] , a : { b : 'cd' , x : 'y' , y : 'x' } } ) ;
8886 await session1 . dispose ( ) ;
8987 await session2 . dispose ( ) ;
9088 await local2 . stop ( ) ;
0 commit comments