@@ -13,44 +13,44 @@ const testPlugin = (code, options) => {
1313describe ( 'plugin' , ( ) => {
1414 it ( 'should add title attribute if not present' , ( ) => {
1515 expect ( testPlugin ( '<svg></svg>' ) ) . toMatchInlineSnapshot (
16- `"<svg>{title ? <title>{title}</title> : null}</svg>;"` ,
16+ `"<svg>{title ? <title id={titleId} >{title}</title> : null}</svg>;"` ,
1717 )
1818 } )
1919
2020 it ( 'should add title element and fallback to existing title' , ( ) => {
2121 // testing when the existing title contains a simple string
2222 expect ( testPlugin ( `<svg><title>Hello</title></svg>` ) ) . toMatchInlineSnapshot (
23- `"<svg>{title === undefined ? <title>Hello</title> : title ? <title>{title}</title> : null}</svg>;"` ,
23+ `"<svg>{title === undefined ? <title id={titleId} >Hello</title> : title ? <title id={titleId} >{title}</title> : null}</svg>;"` ,
2424 )
2525 // testing when the existing title contains an JSXExpression
2626 expect (
2727 testPlugin ( `<svg><title>{"Hello"}</title></svg>` ) ,
2828 ) . toMatchInlineSnapshot (
29- `"<svg>{title === undefined ? <title>{\\"Hello\\"}</title> : title ? <title>{title}</title> : null}</svg>;"` ,
29+ `"<svg>{title === undefined ? <title id={titleId} >{\\"Hello\\"}</title> : title ? <title id={titleId} >{title}</title> : null}</svg>;"` ,
3030 )
3131 } )
3232 it ( 'should preserve any existing title attributes' , ( ) => {
3333 // testing when the existing title contains a simple string
3434 expect (
35- testPlugin ( `<svg><title attr ='a'>Hello</title></svg>` ) ,
35+ testPlugin ( `<svg><title id ='a'>Hello</title></svg>` ) ,
3636 ) . toMatchInlineSnapshot (
37- `"<svg>{title === undefined ? <title attr= 'a'>Hello</title> : title ? <title attr= 'a'>{title}</title> : null}</svg>;"` ,
37+ `"<svg>{title === undefined ? <title id={titleId || 'a'} >Hello</title> : title ? <title id={titleId || 'a'} >{title}</title> : null}</svg>;"` ,
3838 )
3939 } )
4040 it ( 'should support empty title' , ( ) => {
4141 expect ( testPlugin ( '<svg><title></title></svg>' ) ) . toMatchInlineSnapshot (
42- `"<svg>{title ? <title>{title}</title> : null}</svg>;"` ,
42+ `"<svg>{title ? <title id={titleId} >{title}</title> : null}</svg>;"` ,
4343 )
4444 } )
4545 it ( 'should support self closing title' , ( ) => {
4646 expect ( testPlugin ( '<svg><title /></svg>' ) ) . toMatchInlineSnapshot (
47- `"<svg>{title ? <title>{title}</title> : null}</svg>;"` ,
47+ `"<svg>{title ? <title id={titleId} >{title}</title> : null}</svg>;"` ,
4848 )
4949 } )
5050
5151 it ( 'should work if an attribute is already present' , ( ) => {
5252 expect ( testPlugin ( '<svg><foo /></svg>' ) ) . toMatchInlineSnapshot (
53- `"<svg>{title ? <title>{title}</title> : null}<foo /></svg>;"` ,
53+ `"<svg>{title ? <title id={titleId} >{title}</title> : null}<foo /></svg>;"` ,
5454 )
5555 } )
5656} )
0 commit comments