11import { color } from 'nano-theme' ;
22import { type Kit , runAlphabetKitTestSuite } from '../../../../json-crdt-extensions/peritext/__tests__/setup' ;
33import { ArrApi , ObjApi } from '../../../../json-crdt/model' ;
4- import { SliceTypeCon } from '../../slice/constants' ;
4+ import { SliceTypeCon } from '../../slice/constants' ;
55import { PersistedSlice } from '../../slice/PersistedSlice' ;
6- import { getEventsKit } from './setup' ;
6+ import { getEventsKit } from './setup' ;
77
88const testSuite = ( getKit : ( ) => Kit ) => {
99 const setup = ( ) => getEventsKit ( getKit ) ;
@@ -100,7 +100,7 @@ const testSuite = (getKit: () => Kit) => {
100100 kit . et . format ( { action : 'ins' , type : SliceTypeCon . b } ) ;
101101 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
102102 kit . et . format ( { action : 'ins' , type : SliceTypeCon . i } ) ;
103- kit . et . cursor ( { at : [ 0 ] } )
103+ kit . et . cursor ( { at : [ 0 ] } ) ;
104104 expect ( kit . toHtml ( ) ) . toBe ( '<p>abcde<b>fghij</b><i><b>klmno</b></i><i>pqrst</i>uvwxyz</p>' ) ;
105105 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . i ) ;
106106 kit . et . cursor ( { clear : true } ) ;
@@ -115,7 +115,7 @@ const testSuite = (getKit: () => Kit) => {
115115 kit . et . format ( { action : 'ins' , type : SliceTypeCon . b } ) ;
116116 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
117117 kit . et . format ( { action : 'ins' , type : SliceTypeCon . i } ) ;
118- kit . et . cursor ( { at : [ 0 ] } )
118+ kit . et . cursor ( { at : [ 0 ] } ) ;
119119 expect ( kit . toHtml ( ) ) . toBe ( '<p>abcde<b>fghij</b><i><b>klmno</b></i><i>pqrst</i>uvwxyz</p>' ) ;
120120 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . b ) ! ;
121121 kit . et . cursor ( { clear : true } ) ;
@@ -171,11 +171,13 @@ const testSuite = (getKit: () => Kit) => {
171171 test ( 'can diff an "obj" node' , ( ) => {
172172 const kit = setup ( ) ;
173173 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
174- kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : .5 } } ) ;
175- expect ( kit . toHtml ( ) ) . toBe ( '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ) ;
174+ kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : 0.5 } } ) ;
175+ expect ( kit . toHtml ( ) ) . toBe (
176+ '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ,
177+ ) ;
176178 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . col ) ! ;
177179 expect ( slice . data ( ) ) . toEqual ( { color : 'green' , opacity : 0.5 } ) ;
178- kit . et . format ( { action : 'upd' , slice, data : { " color" : " green" , " opacity" : 1 } } ) ;
180+ kit . et . format ( { action : 'upd' , slice, data : { color : ' green' , opacity : 1 } } ) ;
179181 expect ( slice . data ( ) ) . toEqual ( { color : 'green' , opacity : 1 } ) ;
180182 } ) ;
181183
@@ -186,7 +188,7 @@ const testSuite = (getKit: () => Kit) => {
186188 expect ( kit . toHtml ( ) ) . toBe ( '<p>abcdefghij<col data-attr=\'["data"]\'>klmnopqrst</col>uvwxyz</p>' ) ;
187189 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . col ) ! ;
188190 expect ( slice . data ( ) ) . toEqual ( [ 'data' ] ) ;
189- kit . et . format ( { action : 'upd' , slice, data : { " color" : " green" , " opacity" : 1 } } ) ;
191+ kit . et . format ( { action : 'upd' , slice, data : { color : ' green' , opacity : 1 } } ) ;
190192 expect ( slice . data ( ) ) . toEqual ( { color : 'green' , opacity : 1 } ) ;
191193 } ) ;
192194
@@ -206,19 +208,23 @@ const testSuite = (getKit: () => Kit) => {
206208 test ( 'can overwrite formatting data' , ( ) => {
207209 const kit = setup ( ) ;
208210 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
209- kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : .5 } } ) ;
210- expect ( kit . toHtml ( ) ) . toBe ( '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ) ;
211+ kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : 0.5 } } ) ;
212+ expect ( kit . toHtml ( ) ) . toBe (
213+ '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ,
214+ ) ;
211215 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . col ) ! ;
212216 expect ( slice . data ( ) ) . toEqual ( { color : 'green' , opacity : 0.5 } ) ;
213- kit . et . format ( { action : 'set' , slice, data : { " color" : " red" } } ) ;
217+ kit . et . format ( { action : 'set' , slice, data : { color : ' red' } } ) ;
214218 expect ( slice . data ( ) ) . toEqual ( { color : 'red' } ) ;
215219 } ) ;
216220
217221 test ( 'can overwrite formatting data with non-object' , ( ) => {
218222 const kit = setup ( ) ;
219223 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
220- kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : .5 } } ) ;
221- expect ( kit . toHtml ( ) ) . toBe ( '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ) ;
224+ kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : { color : 'green' , opacity : 0.5 } } ) ;
225+ expect ( kit . toHtml ( ) ) . toBe (
226+ '<p>abcdefghij<col data-attr=\'{"color":"green","opacity":0.5}\'>klmnopqrst</col>uvwxyz</p>' ,
227+ ) ;
222228 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . col ) ! ;
223229 expect ( slice . data ( ) ) . toEqual ( { color : 'green' , opacity : 0.5 } ) ;
224230 kit . et . format ( { action : 'set' , slice, data : 123 } ) ;
@@ -229,7 +235,7 @@ const testSuite = (getKit: () => Kit) => {
229235 const kit = setup ( ) ;
230236 kit . et . cursor ( { at : [ 10 , 20 ] } ) ;
231237 kit . et . format ( { action : 'ins' , type : SliceTypeCon . col , data : true } ) ;
232- expect ( kit . toHtml ( ) ) . toBe ( ' <p>abcdefghij<col data-attr=\ 'true\ '>klmnopqrst</col>uvwxyz</p>' ) ;
238+ expect ( kit . toHtml ( ) ) . toBe ( " <p>abcdefghij<col data-attr='true'>klmnopqrst</col>uvwxyz</p>" ) ;
233239 const slice = kit . peritext . savedSlices . each ( ) . find ( ( { type} ) => type === SliceTypeCon . col ) ! ;
234240 expect ( slice . data ( ) ) . toEqual ( true ) ;
235241 kit . et . format ( { action : 'set' , slice, data : { col : '#fff' } } ) ;
0 commit comments