@@ -65,27 +65,26 @@ describe('Validate wordSplitter', () => {
65
65
expect ( r ) . toMatchSnapshot ( ) ; // Use snapshots to ensure all possible options are generated.
66
66
} ) ;
67
67
68
- interface PartialTextOffsetWithIsFound {
68
+ interface PartialTextOffsetWithValid {
69
69
text : string ;
70
70
offset ?: number ;
71
71
isFound ?: boolean ;
72
72
}
73
73
74
74
interface TestSplit {
75
75
text : string ;
76
- expectedWords : PartialTextOffsetWithIsFound [ ] ;
76
+ expectedWords : PartialTextOffsetWithValid [ ] ;
77
77
}
78
78
79
- /** to PartialTextOffsetWithIsFound */
80
- function tov ( p : PartialTextOffsetWithIsFound | string , defaultIsFound = true ) : PartialTextOffsetWithIsFound {
79
+ function tov ( p : PartialTextOffsetWithValid | string , isValid = true ) : PartialTextOffsetWithValid {
81
80
if ( typeof p === 'string' ) {
82
81
p = { text : p } ;
83
82
}
84
- const { isFound = defaultIsFound } = p ;
83
+ const { isFound = isValid } = p ;
85
84
return { ...p , isFound } ;
86
85
}
87
86
88
- function splitTov ( t : string ) : PartialTextOffsetWithIsFound [ ] {
87
+ function splitTov ( t : string ) : PartialTextOffsetWithValid [ ] {
89
88
if ( ! t ) return [ ] ;
90
89
const parts = t . split ( '|' ) ;
91
90
return parts . map ( ( p ) => tov ( p , has ( { text : p , offset : 0 } ) ) ) ;
@@ -174,13 +173,11 @@ describe('Validate wordSplitter', () => {
174
173
${ 'nstatic' } | ${ 'static' } | ${ 1 }
175
174
${ 'techo' } | ${ 'echo' } | ${ 1 }
176
175
${ `n'cpp` } | ${ 'cpp' } | ${ 1 }
177
- ${ `n'log` } | ${ 'log' } | ${ 7 }
176
+ ${ `n'log` } | ${ 'log' } | ${ 4 }
178
177
${ '64-bit' } | ${ 'bit' } | ${ 1 }
179
178
${ '128-bit' } | ${ 'bit' } | ${ 1 }
180
179
${ '256-sha' } | ${ '256-sha' } | ${ 6 }
181
180
${ `REFACTOR'd` } | ${ 'REFACTOR' } | ${ 2 }
182
- ${ `dogs'` } | ${ `dogs'` } | ${ 2 }
183
- ${ `planets’` } | ${ `planets’` } | ${ 2 }
184
181
` ( 'split `$text` in doc' , ( { text, expectedWords, calls } : TestSplit2 ) => {
185
182
const expectedWordSegments = splitTov ( expectedWords ) ;
186
183
const doc = sampleText ( ) ;
@@ -321,10 +318,6 @@ function sampleWordSet() {
321
318
well educated
322
319
words separated by singleQuote
323
320
256-sha
324
- dogs'
325
- leashes
326
- writers
327
- planets’
328
321
`
329
322
. split ( / \s + / g)
330
323
. map ( ( a ) => a . trim ( ) )
@@ -350,11 +343,8 @@ function sampleText() {
350
343
351
344
256-sha
352
345
353
- - The dogs' leashes (multiple dogs).
354
- - The writers' desks (multiple writers).
355
- - The planets’ atmospheres (multiple planets).
356
-
357
346
128-bit values
358
347
348
+
359
349
` ;
360
350
}
0 commit comments