@@ -150,220 +150,127 @@ suite('Tests for Wrap with Abbreviations', () => {
150150 <!-- /.hello -->
151151 </ul>
152152 ` ;
153-
154- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
155- editor . selections = [ new Selection ( 2 , 0 , 2 , 0 ) ] ;
156- const promise = wrapWithAbbreviation ( { abbreviation : 'li.hello|c' } ) ;
157- if ( ! promise ) {
158- assert . equal ( 1 , 2 , 'Wrap returned undefined instead of promise.' ) ;
159- return Promise . resolve ( ) ;
160- }
161- return promise . then ( ( ) => {
162- assert . equal ( editor . document . getText ( ) , expectedContents ) ;
163- return Promise . resolve ( ) ;
164- } ) ;
153+ return testWrapWithAbbreviation ( [ new Selection ( 2 , 0 , 2 , 0 ) ] , 'li.hello|c' , expectedContents , contents ) ;
165154 } ) ;
166- } ) ;
167155
168- test ( 'Wrap with abbreviation entire node when cursor is on opening tag' , ( ) => {
169- const contents = `
170- <div class="nav main">
171- hello
172- </div>
173- ` ;
174- const expectedContents = `
175- <div>
156+ test ( 'Wrap with abbreviation entire node when cursor is on opening tag' , ( ) => {
157+ const contents = `
176158 <div class="nav main">
177159 hello
178160 </div>
179- </div>
180- ` ;
181-
182- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
183- editor . selections = [ new Selection ( 1 , 1 , 1 , 1 ) ] ;
184- const promise = wrapWithAbbreviation ( { abbreviation : 'div' } ) ;
185- if ( ! promise ) {
186- assert . equal ( 1 , 2 , 'Wrap returned undefined instead of promise.' ) ;
187- return Promise . resolve ( ) ;
188- }
189- return promise . then ( ( ) => {
190- assert . equal ( editor . document . getText ( ) , expectedContents ) ;
191- return Promise . resolve ( ) ;
192- } ) ;
161+ ` ;
162+ const expectedContents = `
163+ <div>
164+ <div class="nav main">
165+ hello
166+ </div>
167+ </div>
168+ ` ;
169+ return testWrapWithAbbreviation ( [ new Selection ( 1 , 1 , 1 , 1 ) ] , 'div' , expectedContents , contents ) ;
193170 } ) ;
194- } ) ;
195171
196- test ( 'Wrap with abbreviation entire node when cursor is on closing tag' , ( ) => {
197- const contents = `
198- <div class="nav main">
199- hello
200- </div>
201- ` ;
202- const expectedContents = `
203- <div>
172+ test ( 'Wrap with abbreviation entire node when cursor is on closing tag' , ( ) => {
173+ const contents = `
204174 <div class="nav main">
205175 hello
206176 </div>
207- </div>
208- ` ;
209-
210- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
211- editor . selections = [ new Selection ( 3 , 1 , 3 , 1 ) ] ;
212- const promise = wrapWithAbbreviation ( { abbreviation : 'div' } ) ;
213- if ( ! promise ) {
214- assert . equal ( 1 , 2 , 'Wrap returned undefined instead of promise.' ) ;
215- return Promise . resolve ( ) ;
216- }
217- return promise . then ( ( ) => {
218- assert . equal ( editor . document . getText ( ) , expectedContents ) ;
219- return Promise . resolve ( ) ;
220- } ) ;
221- } ) ;
222- } ) ;
223-
224- test ( 'Wrap with multiline abbreviation doesnt add extra spaces' , ( ) => {
225- // Issue #29898
226- const contents = `
227- hello
228- ` ;
229- const expectedContents = `
230- <ul>
231- <li><a href="">hello</a></li>
232- </ul>
233- ` ;
234-
235- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
236- editor . selections = [ new Selection ( 1 , 2 , 1 , 2 ) ] ;
237- const promise = wrapWithAbbreviation ( { abbreviation : 'ul>li>a' } ) ;
238- if ( ! promise ) {
239- assert . equal ( 1 , 2 , 'Wrap returned undefined instead of promise.' ) ;
240- return Promise . resolve ( ) ;
241- }
242- return promise . then ( ( ) => {
243- assert . equal ( editor . document . getText ( ) , expectedContents ) ;
244- return Promise . resolve ( ) ;
245- } ) ;
177+ ` ;
178+ const expectedContents = `
179+ <div>
180+ <div class="nav main">
181+ hello
182+ </div>
183+ </div>
184+ ` ;
185+ return testWrapWithAbbreviation ( [ new Selection ( 3 , 1 , 3 , 1 ) ] , 'div' , expectedContents , contents ) ;
246186 } ) ;
247- } ) ;
248187
249- test ( 'Wrap individual lines with abbreviation' , ( ) => {
250- const contents = `
251- <ul class="nav main">
252- <li class="item1">This $10 is not a tabstop</li>
253- <li class="item2">hi.there</li>
254- </ul>
255- ` ;
256- const wrapIndividualLinesExpected = `
257- <ul class="nav main">
188+ test ( 'Wrap with multiline abbreviation doesnt add extra spaces' , ( ) => {
189+ // Issue #29898
190+ const contents = `
191+ hello
192+ ` ;
193+ const expectedContents = `
258194 <ul>
259- <li class="hello1"><li class="item1">This $10 is not a tabstop</li></li>
260- <li class="hello2"><li class="item2">hi.there</li></li>
195+ <li><a href="">hello</a></li>
261196 </ul>
262- </ul>
263- ` ;
264- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
265- editor . selections = [ new Selection ( 2 , 2 , 3 , 33 ) ] ;
266- const promise = wrapIndividualLinesWithAbbreviation ( { abbreviation : 'ul>li.hello$*' } ) ;
267- if ( ! promise ) {
268- assert . equal ( 1 , 2 , 'Wrap Individual Lines with Abbreviation returned undefined.' ) ;
269- return Promise . resolve ( ) ;
270- }
271- return promise . then ( ( ) => {
272- assert . equal ( editor . document . getText ( ) , wrapIndividualLinesExpected ) ;
273- return Promise . resolve ( ) ;
274- } ) ;
197+ ` ;
198+ return testWrapWithAbbreviation ( [ new Selection ( 1 , 2 , 1 , 2 ) ] , 'ul>li>a' , expectedContents , contents ) ;
275199 } ) ;
276- } ) ;
277200
278- test ( 'Wrap individual lines with abbreviation with extra space selected ' , ( ) => {
279- const contents = `
280- <ul class="nav main">
281- <li class="item1">img </li>
282- <li class="item2">hi.there</li>
283- </ul>
201+ test ( 'Wrap individual lines with abbreviation' , ( ) => {
202+ const contents = `
203+ <ul class="nav main">
204+ <li class="item1">This $10 is not a tabstop </li>
205+ <li class="item2">hi.there</li>
206+ </ul>
284207` ;
285- const wrapIndividualLinesExpected = `
286- <ul class="nav main">
287- <ul>
288- <li class="hello1"><li class="item1">img</li></li>
289- <li class="hello2"><li class="item2">hi.there</li></li>
208+ const wrapIndividualLinesExpected = `
209+ <ul class="nav main">
210+ <ul>
211+ <li class="hello1"><li class="item1">This $10 is not a tabstop</li></li>
212+ <li class="hello2"><li class="item2">hi.there</li></li>
213+ </ul>
290214 </ul>
291- </ul>
292215` ;
293- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
294- editor . selections = [ new Selection ( 2 , 1 , 4 , 0 ) ] ;
295- const promise = wrapIndividualLinesWithAbbreviation ( { abbreviation : 'ul>li.hello$*' } ) ;
296- if ( ! promise ) {
297- assert . equal ( 1 , 2 , 'Wrap Individual Lines with Abbreviation returned undefined.' ) ;
298- return Promise . resolve ( ) ;
299- }
300- return promise . then ( ( ) => {
301- assert . equal ( editor . document . getText ( ) , wrapIndividualLinesExpected ) ;
302- return Promise . resolve ( ) ;
303- } ) ;
216+ return testWrapIndividualLinesWithAbbreviation ( [ new Selection ( 2 , 2 , 3 , 33 ) ] , 'ul>li.hello$*' , wrapIndividualLinesExpected , contents ) ;
304217 } ) ;
305- } ) ;
306218
307- test ( 'Wrap individual lines with abbreviation with comment filter ' , ( ) => {
308- const contents = `
309- <ul class="nav main">
310- <li class="item1">img</li>
311- <li class="item2">hi.there</li>
312- </ul>
219+ test ( 'Wrap individual lines with abbreviation with extra space selected ' , ( ) => {
220+ const contents = `
221+ <ul class="nav main">
222+ <li class="item1">img</li>
223+ <li class="item2">hi.there</li>
224+ </ul>
313225` ;
314- const wrapIndividualLinesExpected = `
315- <ul class="nav main">
316- <ul>
317- <li class="hello"><li class="item1">img</li></li>
318- <!-- /.hello -->
319- <li class="hello"><li class="item2">hi.there</li></li>
320- <!-- /.hello -->
226+ const wrapIndividualLinesExpected = `
227+ <ul class="nav main">
228+ <ul>
229+ <li class="hello1"><li class="item1">img</li></li>
230+ <li class="hello2"><li class="item2">hi.there</li></li>
231+ </ul>
321232 </ul>
322- </ul>
323233` ;
324- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
325- editor . selections = [ new Selection ( 2 , 2 , 3 , 33 ) ] ;
326- const promise = wrapIndividualLinesWithAbbreviation ( { abbreviation : 'ul>li.hello*|c' } ) ;
327- if ( ! promise ) {
328- assert . equal ( 1 , 2 , 'Wrap Individual Lines with Abbreviation returned undefined.' ) ;
329- return Promise . resolve ( ) ;
330- }
331- return promise . then ( ( ) => {
332- assert . equal ( editor . document . getText ( ) , wrapIndividualLinesExpected ) ;
333- return Promise . resolve ( ) ;
334- } ) ;
234+ return testWrapIndividualLinesWithAbbreviation ( [ new Selection ( 2 , 1 , 4 , 0 ) ] , 'ul>li.hello$*' , wrapIndividualLinesExpected , contents ) ;
335235 } ) ;
336- } ) ;
337236
338- test ( 'Wrap individual lines with abbreviation and trim ' , ( ) => {
339- const contents = `
237+ test ( 'Wrap individual lines with abbreviation with comment filter ' , ( ) => {
238+ const contents = `
340239 <ul class="nav main">
341- • lorem ipsum
342- • lorem ipsum
240+ <li class="item1">img</li>
241+ <li class="item2">hi.there</li>
343242 </ul>
344243` ;
345- const wrapIndividualLinesExpected = `
244+ const wrapIndividualLinesExpected = `
346245 <ul class="nav main">
347246 <ul>
348- <li class="hello1">lorem ipsum</li>
349- <li class="hello2">lorem ipsum</li>
247+ <li class="hello"><li class="item1">img</li></li>
248+ <!-- /.hello -->
249+ <li class="hello"><li class="item2">hi.there</li></li>
250+ <!-- /.hello -->
350251 </ul>
351252 </ul>
352253` ;
353- return withRandomFileEditor ( contents , 'html' , ( editor , _ ) => {
354- editor . selections = [ new Selection ( 2 , 3 , 3 , 16 ) ] ;
355- const promise = wrapIndividualLinesWithAbbreviation ( { abbreviation : 'ul>li.hello$*|t' } ) ;
356- if ( ! promise ) {
357- assert . equal ( 1 , 2 , 'Wrap Individual Lines with Abbreviation returned undefined.' ) ;
358- return Promise . resolve ( ) ;
359- }
254+ return testWrapIndividualLinesWithAbbreviation ( [ new Selection ( 2 , 2 , 3 , 33 ) ] , 'ul>li.hello*|c' , wrapIndividualLinesExpected , contents ) ;
255+ } ) ;
360256
361- return promise . then ( ( ) => {
362- assert . equal ( editor . document . getText ( ) , wrapIndividualLinesExpected ) ;
363- return Promise . resolve ( ) ;
364- } ) ;
257+ test ( 'Wrap individual lines with abbreviation and trim' , ( ) => {
258+ const contents = `
259+ <ul class="nav main">
260+ • lorem ipsum
261+ • lorem ipsum
262+ </ul>
263+ ` ;
264+ const wrapIndividualLinesExpected = `
265+ <ul class="nav main">
266+ <ul>
267+ <li class="hello1">lorem ipsum</li>
268+ <li class="hello2">lorem ipsum</li>
269+ </ul>
270+ </ul>
271+ ` ;
272+ return testWrapIndividualLinesWithAbbreviation ( [ new Selection ( 2 , 3 , 3 , 16 ) ] , 'ul>li.hello$*|t' , wrapIndividualLinesExpected , contents ) ;
365273 } ) ;
366- } ) ;
367274
368275 test ( 'Wrap with abbreviation and format set to false' , ( ) => {
369276 return workspace . getConfiguration ( 'emmet' ) . update ( 'syntaxProfiles' , { 'html' : { 'format' : false } } , ConfigurationTarget . Global ) . then ( ( ) => {
0 commit comments