@@ -121,76 +121,66 @@ describe('highlightText', function () {
121
121
highlight ( elem , [ 'b' ] )
122
122
const portions = this . wrapMatch . firstCall . args [ 0 ]
123
123
124
- expect ( portions . length ) . to . equal ( 1 )
124
+ expect ( portions . length ) . to . equal ( 1 , 'portions.length' )
125
125
expect ( portions [ 0 ] . text ) . to . equal ( 'b' )
126
- expect ( portions [ 0 ] . offset ) . to . equal ( 0 )
127
- expect ( portions [ 0 ] . length ) . to . equal ( 1 )
128
- expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true )
126
+ expect ( portions [ 0 ] . offset ) . to . equal ( 2 , 'offset' )
127
+ expect ( portions [ 0 ] . length ) . to . equal ( 1 , 'length' )
128
+ expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true , 'isLastPortion' )
129
129
} )
130
130
131
131
it ( 'finds a word that is in a text node with a character before' , function ( ) {
132
132
const elem = createParagraphWithTextNodes ( 'a' , ' b' , ' c' )
133
133
highlight ( elem , [ 'b' ] )
134
134
const portions = this . wrapMatch . firstCall . args [ 0 ]
135
135
136
- expect ( portions . length ) . to . equal ( 1 )
136
+ expect ( portions . length ) . to . equal ( 1 , 'portions.length' )
137
137
expect ( portions [ 0 ] . text ) . to . equal ( 'b' )
138
- expect ( portions [ 0 ] . offset ) . to . equal ( 1 )
139
- expect ( portions [ 0 ] . length ) . to . equal ( 1 )
140
- expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true )
138
+ expect ( portions [ 0 ] . offset ) . to . equal ( 2 , 'offset' )
139
+ expect ( portions [ 0 ] . length ) . to . equal ( 1 , 'length' )
140
+ expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true , 'isLastPortion' )
141
141
} )
142
142
143
143
it ( 'finds a word that is in a text node with a charcter after' , function ( ) {
144
144
const elem = createParagraphWithTextNodes ( 'a ' , 'b x' , 'c' )
145
145
highlight ( elem , [ 'b' ] )
146
146
const portions = this . wrapMatch . firstCall . args [ 0 ]
147
147
148
- expect ( portions . length ) . to . equal ( 1 )
148
+ expect ( portions . length ) . to . equal ( 1 , 'portions.length' )
149
149
expect ( portions [ 0 ] . text ) . to . equal ( 'b' )
150
- expect ( portions [ 0 ] . offset ) . to . equal ( 0 )
151
- expect ( portions [ 0 ] . length ) . to . equal ( 1 )
152
- expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true )
150
+ expect ( portions [ 0 ] . offset ) . to . equal ( 2 , 'offset' )
151
+ expect ( portions [ 0 ] . length ) . to . equal ( 1 , 'length' )
152
+ expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true , 'isLastPortion' )
153
153
} )
154
154
155
155
it ( 'finds a word that span over two text nodes' , function ( ) {
156
156
const elem = createParagraphWithTextNodes ( 'a ' , 'b' , 'c' )
157
157
highlight ( elem , [ 'bc' ] )
158
158
const portions = this . wrapMatch . firstCall . args [ 0 ]
159
159
160
- expect ( portions . length ) . to . equal ( 2 )
161
- expect ( portions [ 0 ] . text ) . to . equal ( 'b' )
162
- expect ( portions [ 0 ] . isLastPortion ) . to . equal ( false )
163
-
164
- expect ( portions [ 1 ] . text ) . to . equal ( 'c' )
165
- expect ( portions [ 1 ] . isLastPortion ) . to . equal ( true )
160
+ expect ( portions . length ) . to . equal ( 1 , portions . length )
161
+ expect ( portions [ 0 ] . text ) . to . equal ( 'bc' )
162
+ expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true , 'isLastPortion' )
166
163
} )
167
164
168
165
it ( 'finds a word that spans over three text nodes' , function ( ) {
169
166
const elem = createParagraphWithTextNodes ( 'a' , 'b' , 'c' )
170
167
highlight ( elem , [ 'abc' ] )
171
168
const portions = this . wrapMatch . firstCall . args [ 0 ]
172
169
173
- expect ( portions . length ) . to . equal ( 3 )
174
- expect ( portions [ 0 ] . text ) . to . equal ( 'a' )
175
- expect ( portions [ 1 ] . text ) . to . equal ( 'b' )
176
- expect ( portions [ 2 ] . text ) . to . equal ( 'c' )
170
+ expect ( portions . length ) . to . equal ( 1 , 'portions.length' )
171
+ expect ( portions [ 0 ] . text ) . to . equal ( 'abc' )
177
172
} )
178
173
179
174
it ( 'finds a word that is partially contained in two text nodes' , function ( ) {
180
175
const elem = createParagraphWithTextNodes ( 'a' , ' xx' , 'xx ' )
181
176
highlight ( elem , [ 'xxxx' ] )
182
177
const portions = this . wrapMatch . firstCall . args [ 0 ]
183
178
184
- expect ( portions . length ) . to . equal ( 2 )
185
- expect ( portions [ 0 ] . text ) . to . equal ( 'xx' )
186
- expect ( portions [ 0 ] . offset ) . to . equal ( 1 )
187
- expect ( portions [ 0 ] . length ) . to . equal ( 2 )
188
- expect ( portions [ 0 ] . isLastPortion ) . to . equal ( false )
189
-
190
- expect ( portions [ 1 ] . text ) . to . equal ( 'xx' )
191
- expect ( portions [ 1 ] . offset ) . to . equal ( 0 )
192
- expect ( portions [ 1 ] . length ) . to . equal ( 2 )
193
- expect ( portions [ 1 ] . isLastPortion ) . to . equal ( true )
179
+ expect ( portions . length ) . to . equal ( 1 , 'portions.length' )
180
+ expect ( portions [ 0 ] . text ) . to . equal ( 'xxxx' )
181
+ expect ( portions [ 0 ] . offset ) . to . equal ( 2 , 'offset' )
182
+ expect ( portions [ 0 ] . length ) . to . equal ( 4 , 'length' )
183
+ expect ( portions [ 0 ] . isLastPortion ) . to . equal ( true )
194
184
} )
195
185
} )
196
186
0 commit comments