@@ -35,6 +35,53 @@ describe('svgo', () => {
3535 const result = optimize ( '<svg />' , { input : 'file' , path : 'input.svg' } ) ;
3636 expect ( result . data ) . toEqual ( '<svg/>' ) ;
3737 } ) ;
38+ it ( 'should resolve and not escape numeric character references' , async ( ) => {
39+ const result = optimize ( '<svg><text class="Ӓ ꯍ">ꯍ Ӓ</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
40+ expect ( result . data ) . toEqual ( '<svg><text class="\u04d2 \uabcd">\uabcd \u04d2</text></svg>' ) ;
41+ } ) ;
42+
43+ it ( 'should escape and not double-escape numeric character references representing <' , async ( ) => {
44+ const result = optimize ( '<svg><text font-family="< and <">< and <</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
45+ console . log ( 'result5' , result ) ;
46+ expect ( result . data ) . toEqual ( '<svg><text font-family="< and <">< and <</text></svg>' ) ;
47+ } ) ;
48+ it ( 'should escape and not double-escape numeric character references representing &' , async ( ) => {
49+ const result = optimize ( '<svg><text font-family="& and &">& and &</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
50+ console . log ( 'result6' , result ) ;
51+ expect ( result . data ) . toEqual ( '<svg><text font-family="& and &">& and &</text></svg>' ) ;
52+ } ) ;
53+
54+ // '<svg><text><![CDATA ]> and ]> ]></text></svg>'
55+ // '<svg><text class="" and '">" and '</text></svg>',
56+ // '<svg><text class="" and '">" and '</text></svg>',
57+ it ( 'should escape and not double-escape numeric character references representing >' , async ( ) => {
58+ const result = optimize ( '<svg><text>CDATA1: <![CDATA[ ]> and ]> ]]></text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
59+ console . log ( 'result7' , result ) ;
60+ expect ( result . data ) . toEqual ( '<svg><text>CDATA1: <![CDATA[ ]> and ]> ]]></text></svg>' ) ;
61+ } ) ;
62+ it ( 'should escape and not double-escape numeric character references representing \'' , async ( ) => {
63+ const result = optimize ( '<svg><text class="" and '">" and '</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
64+ console . log ( 'result8' , result ) ;
65+ expect ( result . data ) . toEqual ( '<svg><text class="" and \'">" and '</text></svg>' ) ;
66+ } ) ;
67+ it ( 'should escape and not double-escape numeric character references representing "' , async ( ) => {
68+ const result = optimize ( '<svg><text class="" and '">" and '</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
69+ console . log ( 'result9' , result ) ;
70+ expect ( result . data ) . toEqual ( '<svg><text class="" and \'">" and '</text></svg>' ) ;
71+ } ) ;
72+
73+ it ( 'should escape and not double-escape numeric character references representing \'' , async ( ) => {
74+ const result = optimize ( '<svg><text class=\'" and '\'>" and '</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
75+ console . log ( 'result8' , result ) ;
76+ expect ( result . data ) . toEqual ( '<svg><text class="" and \'">" and '</text></svg>' ) ;
77+ } ) ;
78+ it ( 'should escape and not double-escape numeric character references representing "' , async ( ) => {
79+ const result = optimize ( '<svg><text class="" and '">" and '</text></svg>' , { input : 'file' , path : 'input.svg' } ) ;
80+ console . log ( 'result9' , result ) ;
81+ expect ( result . data ) . toEqual ( '<svg><text class="" and \'">" and '</text></svg>' ) ;
82+ } ) ;
83+
84+
3885 it ( 'should preserve style specifity over attributes' , async ( ) => {
3986 const [ original , expected ] = await parseFixture ( 'style-specifity.svg' ) ;
4087 const result = optimize ( original , {
0 commit comments