1
- import { InlineAttrPos } from '../block/Inline' ;
2
- import { CursorAnchor , SliceTypes } from '../slice/constants' ;
1
+ import { InlineAttrStartPoint , InlineAttrContained } from '../block/Inline' ;
2
+ import { SliceTypes } from '../slice/constants' ;
3
3
import { setupKit } from './setup' ;
4
4
5
5
const setup = ( ) => {
@@ -24,10 +24,8 @@ test('cursor at the start of string and slice annotation at the start of string'
24
24
expect ( inline1 . text ( ) ) . toBe ( '' ) ;
25
25
expect ( inline2 . text ( ) ) . toBe ( 'a' ) ;
26
26
expect ( inline3 . text ( ) ) . toBe ( 'b' ) ;
27
- expect ( inline1 . attr ( ) ) . toEqual ( {
28
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
29
- } ) ;
30
- expect ( inline2 . attr ( ) ) . toEqual ( { bold : [ 1 , InlineAttrPos . Contained ] } ) ;
27
+ expect ( inline1 . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf ( InlineAttrStartPoint ) ;
28
+ expect ( inline2 . attr ( ) . bold [ 0 ] ) . toBeInstanceOf ( InlineAttrContained ) ;
31
29
expect ( inline3 . attr ( ) ) . toEqual ( { } ) ;
32
30
} ) ;
33
31
@@ -49,10 +47,12 @@ test('cursor walking over character marked as bold', () => {
49
47
expect ( inline1 . text ( ) ) . toBe ( '' ) ;
50
48
expect ( inline2 . text ( ) ) . toBe ( 'a' ) ;
51
49
expect ( inline3 . text ( ) ) . toBe ( 'b' ) ;
52
- expect ( inline2 . attr ( ) ) . toEqual ( { bold : [ [ void 0 ] , InlineAttrPos . Contained ] } ) ;
53
- expect ( inline3 . attr ( ) ) . toEqual ( {
54
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
55
- } ) ;
50
+ expect ( inline2 . attr ( ) . bold [ 0 ] ) . toBeInstanceOf ( InlineAttrContained ) ;
51
+ expect ( inline3 . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf ( InlineAttrStartPoint ) ;
52
+ // expect(inline2.attr()).toEqual({bold: [[void 0], InlineAttrPos.Contained]});
53
+ // expect(inline3.attr()).toEqual({
54
+ // [SliceTypes.Cursor]: [[[CursorAnchor.Start, void 0]], InlineAttrPos.Collapsed],
55
+ // });
56
56
editor . cursor . move ( 1 ) ;
57
57
peritext . refresh ( ) ;
58
58
} ) ;
@@ -75,11 +75,13 @@ test('cursor walking over character marked as bold and one more', () => {
75
75
expect ( inline2 . text ( ) ) . toBe ( 'a' ) ;
76
76
expect ( inline3 . text ( ) ) . toBe ( 'b' ) ;
77
77
expect ( inline4 . text ( ) ) . toBe ( '' ) ;
78
- expect ( inline2 . attr ( ) ) . toEqual ( { bold : [ 1 , InlineAttrPos . Contained ] } ) ;
78
+ expect ( inline2 . attr ( ) . bold [ 0 ] ) . toBeInstanceOf ( InlineAttrContained ) ;
79
+ // expect(inline2.attr()).toEqual({bold: [1, InlineAttrPos.Contained]});
79
80
expect ( inline3 . attr ( ) ) . toEqual ( { } ) ;
80
- expect ( inline4 . attr ( ) ) . toEqual ( {
81
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
82
- } ) ;
81
+ expect ( inline4 . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf ( InlineAttrStartPoint ) ;
82
+ // expect(inline4.attr()).toEqual({
83
+ // [SliceTypes.Cursor]: [[[CursorAnchor.Start, void 0]], InlineAttrPos.Collapsed],
84
+ // });
83
85
} ) ;
84
86
85
87
test ( 'cursor can move across block boundary forwards' , ( ) => {
@@ -92,19 +94,20 @@ test('cursor can move across block boundary forwards', () => {
92
94
expect ( peritext . blocks . root . children . length ) . toBe ( 2 ) ;
93
95
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] . length ) . toBe ( 1 ) ;
94
96
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 0 ] . text ( ) ) . toBe ( 'a' ) ;
95
- expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 0 ] . attr ( ) ) . toEqual ( {
96
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
97
- } ) ;
97
+ expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 0 ] . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf (
98
+ InlineAttrStartPoint ,
99
+ ) ;
100
+
98
101
editor . cursor . move ( 1 ) ;
99
102
peritext . refresh ( ) ;
100
103
expect ( peritext . blocks . root . children . length ) . toBe ( 2 ) ;
101
104
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] . length ) . toBe ( 2 ) ;
102
105
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 0 ] . text ( ) ) . toBe ( 'a' ) ;
103
106
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 0 ] . attr ( ) ) . toEqual ( { } ) ;
104
107
expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 1 ] . text ( ) ) . toBe ( '' ) ;
105
- expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 1 ] . attr ( ) ) . toEqual ( {
106
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
107
- } ) ;
108
+ expect ( [ ...peritext . blocks . root . children [ 0 ] . texts ( ) ] [ 1 ] . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf (
109
+ InlineAttrStartPoint ,
110
+ ) ;
108
111
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] . length ) . toBe ( 1 ) ;
109
112
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . text ( ) ) . toBe ( 'b' ) ;
110
113
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . attr ( ) ) . toEqual ( { } ) ;
@@ -118,9 +121,9 @@ test('cursor can move across block boundary forwards', () => {
118
121
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . text ( ) ) . toBe ( '' ) ;
119
122
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . attr ( ) ) . toEqual ( { } ) ;
120
123
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . text ( ) ) . toBe ( 'b' ) ;
121
- expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . attr ( ) ) . toEqual ( {
122
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
123
- } ) ;
124
+ expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf (
125
+ InlineAttrStartPoint ,
126
+ ) ;
124
127
editor . cursor . move ( 1 ) ;
125
128
peritext . refresh ( ) ;
126
129
expect ( peritext . blocks . root . children . length ) . toBe ( 2 ) ;
@@ -131,7 +134,7 @@ test('cursor can move across block boundary forwards', () => {
131
134
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . text ( ) ) . toBe ( 'b' ) ;
132
135
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 0 ] . attr ( ) ) . toEqual ( { } ) ;
133
136
expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . text ( ) ) . toBe ( '' ) ;
134
- expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . attr ( ) ) . toEqual ( {
135
- [ SliceTypes . Cursor ] : [ [ [ CursorAnchor . Start , void 0 ] ] , InlineAttrPos . Collapsed ] ,
136
- } ) ;
137
+ expect ( [ ...peritext . blocks . root . children [ 1 ] . texts ( ) ] [ 1 ] . attr ( ) [ SliceTypes . Cursor ] [ 0 ] ) . toBeInstanceOf (
138
+ InlineAttrStartPoint ,
139
+ ) ;
137
140
} ) ;
0 commit comments