@@ -7,22 +7,13 @@ describe('.fromHtml()', () => {
77 test ( 'a single paragraph' , ( ) => {
88 const html = '<p>Hello world</p>' ;
99 const peritextMl = fromHtml ( html ) ;
10- expect ( peritextMl ) . toEqual ( [
11- '' ,
12- null ,
13- [ CommonSliceType . p , null , 'Hello world' ] ,
14- ] ) ;
10+ expect ( peritextMl ) . toEqual ( [ '' , null , [ CommonSliceType . p , null , 'Hello world' ] ] ) ;
1511 } ) ;
1612
1713 test ( 'a paragraph with trailing text' , ( ) => {
1814 const html = '<p>Hello world</p> more text' ;
1915 const peritextMl = fromHtml ( html ) ;
20- expect ( peritextMl ) . toEqual ( [
21- '' ,
22- null ,
23- [ CommonSliceType . p , null , 'Hello world' ] ,
24- ' more text' ,
25- ] ) ;
16+ expect ( peritextMl ) . toEqual ( [ '' , null , [ CommonSliceType . p , null , 'Hello world' ] , ' more text' ] ) ;
2617 } ) ;
2718
2819 test ( 'text formatted as italic' , ( ) => {
@@ -33,10 +24,12 @@ describe('.fromHtml()', () => {
3324 null ,
3425 [ CommonSliceType . p , null , 'Hello world' ] ,
3526 '\n' ,
36- [ CommonSliceType . p , null ,
37- [ CommonSliceType . i , { behavior : SliceBehavior . One , inline :true } , 'italic' ] ,
27+ [
28+ CommonSliceType . p ,
29+ null ,
30+ [ CommonSliceType . i , { behavior : SliceBehavior . One , inline : true } , 'italic' ] ,
3831 ' text, ' ,
39- [ CommonSliceType . i , { behavior : SliceBehavior . One , inline :true } , 'more italic' ] ,
32+ [ CommonSliceType . i , { behavior : SliceBehavior . One , inline : true } , 'more italic' ] ,
4033 ] ,
4134 ] ) ;
4235 } ) ;
@@ -61,31 +54,47 @@ describe('.toViewRange()', () => {
6154 const html = '<p>Hello world</p><p>Goodbye world</p>' ;
6255 const peritextMl = fromHtml ( html ) ;
6356 const view = toViewRange ( peritextMl ) ;
64- expect ( view ) . toEqual ( [ '\nHello world\nGoodbye world' , 0 , [
65- [ 0 , 0 , 0 , 0 ] ,
66- [ 0 , 12 , 12 , 0 ] ,
67- ] ] ) ;
57+ expect ( view ) . toEqual ( [
58+ '\nHello world\nGoodbye world' ,
59+ 0 ,
60+ [
61+ [ 0 , 0 , 0 , 0 ] ,
62+ [ 0 , 12 , 12 , 0 ] ,
63+ ] ,
64+ ] ) ;
6865 } ) ;
6966
7067 test ( 'two paragraphs with whitespace gap' , ( ) => {
7168 const html = ' <p>Hello world</p>\n <p>Goodbye world</p>' ;
7269 const peritextMl = fromHtml ( html ) ;
7370 const view = toViewRange ( peritextMl ) ;
74- expect ( view ) . toEqual ( [ '\nHello world\nGoodbye world' , 0 , [
75- [ 0 , 0 , 0 , 0 ] ,
76- [ 0 , 12 , 12 , 0 ] ,
77- ] ] ) ;
71+ expect ( view ) . toEqual ( [
72+ '\nHello world\nGoodbye world' ,
73+ 0 ,
74+ [
75+ [ 0 , 0 , 0 , 0 ] ,
76+ [ 0 , 12 , 12 , 0 ] ,
77+ ] ,
78+ ] ) ;
7879 } ) ;
7980
8081 test ( 'single inline annotation' , ( ) => {
8182 const html = 'here is some <em>italic</em> text' ;
8283 const peritextMl = fromHtml ( html ) ;
8384 const view = toViewRange ( peritextMl ) ;
84- expect ( view ) . toEqual ( [ 'here is some italic text' , 0 , [
85- [ ( SliceBehavior . One << SliceHeaderShift . Behavior ) +
86- ( Anchor . Before << SliceHeaderShift . X1Anchor ) +
87- ( Anchor . After << SliceHeaderShift . X2Anchor ) ,
88- 13 , 19 , CommonSliceType . i ] ,
89- ] ] ) ;
85+ expect ( view ) . toEqual ( [
86+ 'here is some italic text' ,
87+ 0 ,
88+ [
89+ [
90+ ( SliceBehavior . One << SliceHeaderShift . Behavior ) +
91+ ( Anchor . Before << SliceHeaderShift . X1Anchor ) +
92+ ( Anchor . After << SliceHeaderShift . X2Anchor ) ,
93+ 13 ,
94+ 19 ,
95+ CommonSliceType . i ,
96+ ] ,
97+ ] ,
98+ ] ) ;
9099 } ) ;
91- } ) ;
100+ } ) ;
0 commit comments