@@ -21,7 +21,7 @@ function htmlToText(html: string) {
2121 return div . textContent ?? '' ;
2222}
2323
24- describe ( 'add character diffs ' , ( ) => {
24+ describe ( 'utility code ' , ( ) => {
2525 test ( 'simplifyCodes' , ( ) => {
2626 const x = 'replace' ;
2727 const y = 'equal' ;
@@ -69,6 +69,50 @@ describe('add character diffs', () => {
6969 ) ;
7070 } ) ;
7171
72+ test ( 'splitIntoWords' , ( ) => {
73+ expect ( splitIntoWords ( '<ImageDiffModeSelector filePair={filePair}' ) ) . toEqual ( [
74+ '<' ,
75+ 'Image' ,
76+ 'Diff' ,
77+ 'Mode' ,
78+ 'Selector' ,
79+ ' ' ,
80+ 'file' ,
81+ 'Pair' ,
82+ '=' ,
83+ '{' ,
84+ 'file' ,
85+ 'Pair' ,
86+ '}' ,
87+ ] ) ;
88+ expect ( splitIntoWords ( '<DiffView filePair={filePair}' ) ) . toEqual ( [
89+ '<' ,
90+ 'Diff' ,
91+ 'View' ,
92+ ' ' ,
93+ 'file' ,
94+ 'Pair' ,
95+ '=' ,
96+ '{' ,
97+ 'file' ,
98+ 'Pair' ,
99+ '}' ,
100+ ] ) ;
101+ expect ( splitIntoWords ( 'Test1TEST23testAbc{}' ) ) . toEqual ( [
102+ 'Test' ,
103+ '1' ,
104+ 'TEST' ,
105+ '23' ,
106+ 'test' ,
107+ 'Abc' ,
108+ '{' ,
109+ '}' ,
110+ ] ) ;
111+ expect ( splitIntoWords ( ' FooBar' ) ) . toEqual ( [ ' ' , ' ' , ' ' , 'Foo' , 'Bar' ] ) ;
112+ } ) ;
113+ } ) ;
114+
115+ describe ( 'add character diffs' , ( ) => {
72116 test ( 'char diffs -- simple' , ( ) => {
73117 const beforeText = " return '' + date.getFullYear();" ;
74118 const afterText = " return 'xx' + date.getFullYear();" ;
@@ -109,8 +153,9 @@ describe('add character diffs', () => {
109153 } ) ;
110154
111155 test ( 'mixed inserts and markup' , ( ) => {
112- var beforeHtml = '<span class="hljs-string">"q"</span>, s' ;
113- var afterHtml = '<span class="hljs-string">"q"</span><span class="hljs-comment">/*, s*/</span>' ;
156+ const beforeHtml = '<span class="hljs-string">"q"</span>, s' ;
157+ const afterHtml =
158+ '<span class="hljs-string">"q"</span><span class="hljs-comment">/*, s*/</span>' ;
114159
115160 const beforeText = htmlToText ( beforeHtml ) ;
116161 const afterText = htmlToText ( afterHtml ) ;
@@ -132,20 +177,20 @@ describe('add character diffs', () => {
132177 expect ( codes ) . not . toBeNull ( ) ;
133178 // 'Declined to generate a diff when one was expected.');
134179
135- var beforeCodes = codes [ 0 ] ,
180+ const beforeCodes = codes [ 0 ] ,
136181 afterCodes = codes [ 1 ] ;
137182
138- var process = function ( codes : CharacterDiff [ ] , txt : string ) {
183+ const process = function ( codes : CharacterDiff [ ] , txt : string ) {
139184 return codes
140185 . map ( function ( code ) {
141- var part = txt . substring ( code [ 1 ] , code [ 2 ] ) ;
186+ let part = txt . substring ( code [ 1 ] , code [ 2 ] ) ;
142187 if ( code [ 0 ] != null ) part = '[' + part + ']' ;
143188 return part ;
144189 } )
145190 . join ( '' ) ;
146191 } ;
147192
148- var beforeActual = process ( beforeCodes , beforeText ) ,
193+ const beforeActual = process ( beforeCodes , beforeText ) ,
149194 afterActual = process ( afterCodes , afterText ) ;
150195
151196 expect ( beforeActual ) . toEqual ( beforeExpectation ) ;
@@ -162,48 +207,6 @@ describe('add character diffs', () => {
162207 ) ;
163208 } ) ;
164209
165- test ( 'splitIntoWords' , ( ) => {
166- expect ( splitIntoWords ( '<ImageDiffModeSelector filePair={filePair}' ) ) . toEqual ( [
167- '<' ,
168- 'Image' ,
169- 'Diff' ,
170- 'Mode' ,
171- 'Selector' ,
172- ' ' ,
173- 'file' ,
174- 'Pair' ,
175- '=' ,
176- '{' ,
177- 'file' ,
178- 'Pair' ,
179- '}' ,
180- ] ) ;
181- expect ( splitIntoWords ( '<DiffView filePair={filePair}' ) ) . toEqual ( [
182- '<' ,
183- 'Diff' ,
184- 'View' ,
185- ' ' ,
186- 'file' ,
187- 'Pair' ,
188- '=' ,
189- '{' ,
190- 'file' ,
191- 'Pair' ,
192- '}' ,
193- ] ) ;
194- expect ( splitIntoWords ( 'Test1TEST23testAbc{}' ) ) . toEqual ( [
195- 'Test' ,
196- '1' ,
197- 'TEST' ,
198- '23' ,
199- 'test' ,
200- 'Abc' ,
201- '{' ,
202- '}' ,
203- ] ) ;
204- expect ( splitIntoWords ( ' FooBar' ) ) . toEqual ( [ ' ' , ' ' , ' ' , 'Foo' , 'Bar' ] ) ;
205- } ) ;
206-
207210 test ( 'char diffs on word boundaries' , ( ) => {
208211 assertCharDiff (
209212 '<ImageDiffModeSelector filePair={filePair}' ,
@@ -243,7 +246,7 @@ describe('add character diffs', () => {
243246
244247 assertCharDiff (
245248 'import net.sf.samtools._' ,
246- 'import [net.sf]. samtools._' ,
249+ 'import [net].[sf.] samtools._' ,
247250 'import htsjdk.samtools._' ,
248251 'import [htsjdk].samtools._' ,
249252 ) ;
@@ -262,7 +265,7 @@ describe('add character diffs', () => {
262265 ' <div className="examine-page">' ,
263266 ' <div className="examine-page">' ,
264267 ' <div className="examine-page">' ,
265- '[ ] <div className="examine-page">' ,
268+ ' [ ] <div className="examine-page">' ,
266269 ) ;
267270
268271 assertCharDiff ( 'foobar' , 'foobar' , ' foobar' , '[ ]foobar' ) ;
0 commit comments