import { Client, syncClients, expectClients } from './utils.js'; describe( 'transform', () => { let john, kate; beforeEach( () => { return Promise.all( [ Client.get( 'john' ).then( client => ( john = client ) ), Client.get( 'kate' ).then( client => ( kate = client ) ) ] ); } ); afterEach( () => { return Promise.all( [ john.destroy(), kate.destroy() ] ); } ); describe( 'unwrap', () => { describe( 'by unwrap', () => { it( 'element in different path', () => { john.setData( '
[' + 'Foo ]
' ); kate.setData( 'Bar
' + 'Foo
[' ); john.unwrap(); kate.unwrap(); syncClients(); expectClients( 'Bar ]
' + '[Foo]
' ); kate.setData( 'Bar
' + 'Foo
' ); john.unwrap(); kate.unwrap(); syncClients(); expectClients( '[Bar]
Foo' + '
Bar' ); } ); it( 'the same element', () => { john.setData( '
[' ); kate.setData( 'Foo ]
[' ); john.unwrap(); kate.unwrap(); syncClients(); expectClients( 'Foo ]
[]' ); kate.setData( 'Foo
[]' ); john.unwrap(); kate.unwrap(); syncClients(); expectClients( 'Foo
' ); } ); it( 'the same text', () => { john.setData( 'Foo
' ); kate.setData( '[Foo]
' ); john.unwrap(); kate.unwrap(); syncClients(); expectClients( '[Foo]
Foo' ); } ); it( 'the same text, then undo', () => { john.setData( '
' ); kate.setData( '[Foo]
' ); john.unwrap(); kate.unwrap(); syncClients(); john.undo(); syncClients(); expectClients( '[Foo]
' ); } ); } ); describe( 'by delete', () => { it( 'text from two elements #1', () => { john.setData( 'Foo
[Foo ]
Fo[o
[' ); kate.setData( 'Foo ]
' ); john.unwrap(); kate.delete(); syncClients(); expectClients( 'F[oo]
[' ); kate.setData( 'Foo ]Bar
' ); john.unwrap(); kate.merge(); syncClients(); expectClients( 'Foo []Bar
[' ); kate.setData( 'Foo Bar ]
' ); john.unwrap(); kate.merge(); syncClients(); expectClients( 'Foo []Bar
[' ); kate.setData( 'Bar ]
' ); john.unwrap(); kate.merge(); syncClients(); expectClients( 'Bar