@@ -21,34 +21,40 @@ const parseFixture = async file => {
21
21
describe ( 'svgo' , ( ) => {
22
22
it ( 'should create indent with 2 spaces' , async ( ) => {
23
23
const [ original , expected ] = await parseFixture ( 'test.svg' ) ;
24
- const result = optimize ( original , {
25
- plugins : [ ] ,
26
- js2svg : { pretty : true , indent : 2 } ,
27
- } ) ;
28
- expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
24
+ const result = optimize ( original , {
25
+ plugins : [ ] ,
26
+ js2svg : { pretty : true , indent : 2 } ,
27
+ } ) ;
28
+ expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
29
29
} ) ;
30
30
it ( 'should run multiple times' , async ( ) => {
31
31
const [ original , expected ] = await parseFixture ( 'multipass.svg' ) ;
32
- const result = optimize ( original , {
33
- multipass : true ,
34
- } ) ;
35
- expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
32
+ const result = optimize ( original , {
33
+ multipass : true ,
34
+ } ) ;
35
+ expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
36
36
} ) ;
37
37
it ( 'should pass multipass count to plugins' , async ( ) => {
38
38
const [ original , expected ] = await parseFixture ( 'multipass-prefix-ids.svg' ) ;
39
- const result = optimize ( original , {
40
- multipass : true ,
41
- plugins : extendDefaultPlugins ( [
42
- {
43
- name : 'prefixIds' ,
44
- } ,
45
- ] ) ,
46
- } ) ;
47
- expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
39
+ const result = optimize ( original , {
40
+ multipass : true ,
41
+ plugins : extendDefaultPlugins ( [
42
+ {
43
+ name : 'prefixIds' ,
44
+ } ,
45
+ ] ) ,
46
+ } ) ;
47
+ expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
48
48
} ) ;
49
49
it ( 'should handle plugins order properly' , async ( ) => {
50
50
const [ original , expected ] = await parseFixture ( 'plugins-order.svg' ) ;
51
- const result = optimize ( original , { input : 'file' , path : 'input.svg' } ) ;
52
- expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
51
+ const result = optimize ( original , { input : 'file' , path : 'input.svg' } ) ;
52
+ expect ( normalize ( result . data ) ) . to . equal ( expected ) ;
53
+ } ) ;
54
+ it ( 'should handle parse error' , async ( ) => {
55
+ const fixture = await fs . promises . readFile ( path . resolve ( __dirname , 'invalid.svg' ) ) ;
56
+ const result = optimize ( fixture , { input : 'file' , path : 'input.svg' } ) ;
57
+ expect ( result . error ) . to . match ( / E r r o r i n p a r s i n g S V G / ) ;
58
+ expect ( result . path ) . to . equal ( 'input.svg' ) ;
53
59
} ) ;
54
60
} ) ;
0 commit comments