@@ -274,30 +274,38 @@ test('provides informative error in result', () => {
274274 <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
275275 </svg>
276276 ` ;
277- const { modernError : error } = optimize ( svg , { path : 'test.svg' } ) ;
278- expect ( error . name ) . toEqual ( 'SvgoParserError' ) ;
279- expect ( error . message ) . toEqual ( 'test.svg:2:33: Unquoted attribute value' ) ;
280- expect ( error . reason ) . toEqual ( 'Unquoted attribute value' ) ;
281- expect ( error . line ) . toEqual ( 2 ) ;
282- expect ( error . column ) . toEqual ( 33 ) ;
283- expect ( error . source ) . toEqual ( svg ) ;
277+ try {
278+ optimize ( svg , { path : 'test.svg' } ) ;
279+ expect ( true ) . toEqual ( false ) ;
280+ } catch ( error ) {
281+ expect ( error . name ) . toEqual ( 'SvgoParserError' ) ;
282+ expect ( error . message ) . toEqual ( 'test.svg:2:33: Unquoted attribute value' ) ;
283+ expect ( error . reason ) . toEqual ( 'Unquoted attribute value' ) ;
284+ expect ( error . line ) . toEqual ( 2 ) ;
285+ expect ( error . column ) . toEqual ( 33 ) ;
286+ expect ( error . source ) . toEqual ( svg ) ;
287+ }
284288} ) ;
285289
286290test ( 'provides code snippet in rendered error' , ( ) => {
287291 const svg = `<svg viewBox="0 0 120 120">
288292 <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
289293</svg>
290294` ;
291- const { modernError : error } = optimize ( svg , { path : 'test.svg' } ) ;
292- expect ( error . toString ( ) )
293- . toEqual ( `SvgoParserError: test.svg:2:29: Unquoted attribute value
295+ try {
296+ optimize ( svg , { path : 'test.svg' } ) ;
297+ expect ( true ) . toEqual ( false ) ;
298+ } catch ( error ) {
299+ expect ( error . toString ( ) )
300+ . toEqual ( `SvgoParserError: test.svg:2:29: Unquoted attribute value
294301
295302 1 | <svg viewBox="0 0 120 120">
296303> 2 | <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
297304 | ^
298305 3 | </svg>
299306 4 |
300307` ) ;
308+ }
301309} ) ;
302310
303311test ( 'supports errors without path' , ( ) => {
@@ -314,9 +322,12 @@ test('supports errors without path', () => {
314322 <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
315323</svg>
316324` ;
317- const { modernError : error } = optimize ( svg ) ;
318- expect ( error . toString ( ) )
319- . toEqual ( `SvgoParserError: <input>:11:29: Unquoted attribute value
325+ try {
326+ optimize ( svg ) ;
327+ expect ( true ) . toEqual ( false ) ;
328+ } catch ( error ) {
329+ expect ( error . toString ( ) )
330+ . toEqual ( `SvgoParserError: <input>:11:29: Unquoted attribute value
320331
321332 9 | <circle/>
322333 10 | <circle/>
@@ -325,40 +336,28 @@ test('supports errors without path', () => {
325336 12 | </svg>
326337 13 |
327338` ) ;
339+ }
328340} ) ;
329341
330342test ( 'slices long line in error code snippet' , ( ) => {
331343 const svg = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" viewBox="0 0 230 120">
332344 <path d="M318.198 551.135 530.33 918.56l-289.778-77.646 38.823-144.889c77.646-289.778 294.98-231.543 256.156-86.655s178.51 203.124 217.334 58.235q58.234-217.334 250.955 222.534t579.555 155.292z stroke-width="1.5" fill="red" stroke="red" />
333345</svg>
334346` ;
335- const { modernError : error } = optimize ( svg ) ;
336- expect ( error . toString ( ) )
337- . toEqual ( `SvgoParserError: <input>:2:211: Invalid attribute name
347+ try {
348+ optimize ( svg ) ;
349+ expect ( true ) . toEqual ( false ) ;
350+ } catch ( error ) {
351+ expect ( error . toString ( ) )
352+ . toEqual ( `SvgoParserError: <input>:2:211: Invalid attribute name
338353
339354 1 | …-0.dtd" viewBox="0 0 230 120">
340355> 2 | …7.334 250.955 222.534t579.555 155.292z stroke-width="1.5" fill="red" strok…
341356 | ^
342357 3 |
343358 4 |
344359` ) ;
345- } ) ;
346-
347- test ( 'provides legacy error message' , ( ) => {
348- const svg = `<svg viewBox="0 0 120 120">
349- <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
350- </svg>
351- ` ;
352- const { error } = optimize ( svg , { path : 'test.svg' } ) ;
353- expect ( error )
354- . toEqual ( `SvgoParserError: test.svg:2:29: Unquoted attribute value
355-
356- 1 | <svg viewBox="0 0 120 120">
357- > 2 | <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
358- | ^
359- 3 | </svg>
360- 4 |
361- ` ) ;
360+ }
362361} ) ;
363362
364363test ( 'multipass option should trigger plugins multiple times' , ( ) => {
0 commit comments