@@ -62,6 +62,37 @@ describe('HtmlGenerator', () => {
6262 } ) ;
6363 expect ( obj . build ( m1 ) ) . toEqual ( '<article data-test1="value1" data-test2="value2" class="class1 class2"></article>' ) ;
6464 } ) ;
65+
66+ test ( 'Build correctly component with id preserved when script is defined' , ( ) => {
67+ const m1 = comp . get ( 'components' ) . add ( {
68+ tagName : 'article' ,
69+ } ) ;
70+ m1 . set ( 'script' , 'anything' ) ;
71+ expect ( obj . build ( m1 , { cleanId : true , em } ) ) . toEqual ( `<article id="${ m1 . getId ( ) } "></article>` ) ;
72+ } ) ;
73+
74+ test ( 'Build correctly component with id preserved when script-export is defined' , ( ) => {
75+ const m1 = comp . get ( 'components' ) . add ( {
76+ tagName : 'article' ,
77+ } ) ;
78+ m1 . set ( 'script-export' , 'anything' ) ;
79+ expect ( obj . build ( m1 , { cleanId : true , em } ) ) . toEqual ( `<article id="${ m1 . getId ( ) } "></article>` ) ;
80+ } ) ;
81+
82+ test ( 'Build correctly component with id preserved when id is explicitly set ' , ( ) => {
83+ const m1 = comp . get ( 'components' ) . add ( {
84+ tagName : 'article' ,
85+ } ) ;
86+ m1 . setId ( 'i11' ) ;
87+ expect ( obj . build ( m1 , { cleanId : true , em } ) ) . toEqual ( `<article id="i11"></article>` ) ;
88+ } ) ;
89+
90+ test ( 'Build correctly component with cleanId is enabled and id is not required ' , ( ) => {
91+ const m1 = comp . get ( 'components' ) . add ( {
92+ tagName : 'article' ,
93+ } ) ;
94+ expect ( obj . build ( m1 , { cleanId : true , em } ) ) . toEqual ( `<article></article>` ) ;
95+ } ) ;
6596} ) ;
6697
6798describe ( 'CssGenerator' , ( ) => {
0 commit comments