@@ -172,4 +172,51 @@ describe('parser', () => {
172172 expect ( ( b . childNodes [ 0 ] as TextNode ) . value ) . toBe ( 'should be outside' ) ;
173173 } ) ;
174174 } ) ;
175+
176+ describe ( 'Customizable Select' , ( ) => {
177+ it ( 'should NOT enable selectedcontent for select multiple' , ( ) => {
178+ const html = `
179+ <select multiple>
180+ <button>
181+ <selectedcontent></selectedcontent>
182+ </button>
183+ <option selected>foo</option>
184+ </select>
185+ ` ;
186+
187+ const doc = parse ( html ) ;
188+ const htmlEl = doc . childNodes . find ( ( n ) => n . nodeName === 'html' ) as Element ;
189+ const body = htmlEl . childNodes . find ( ( n ) => n . nodeName === 'body' ) as Element ;
190+ const select = body . childNodes . find ( ( n ) => ( n as Element ) . tagName === 'select' ) as Element ;
191+ const button = select . childNodes . find ( ( n ) => ( n as Element ) . tagName === 'button' ) as Element ;
192+ const selectedcontent = button . childNodes . find (
193+ ( n ) => ( n as Element ) . tagName === 'selectedcontent' ,
194+ ) as Element ;
195+
196+ expect ( selectedcontent . childNodes . length ) . toBe ( 0 ) ;
197+ } ) ;
198+
199+ it ( 'should enable selectedcontent for select without multiple' , ( ) => {
200+ const html = `
201+ <select>
202+ <button>
203+ <selectedcontent></selectedcontent>
204+ </button>
205+ <option selected>foo</option>
206+ </select>
207+ ` ;
208+
209+ const doc = parse ( html ) ;
210+ const htmlEl = doc . childNodes . find ( ( n ) => n . nodeName === 'html' ) as Element ;
211+ const body = htmlEl . childNodes . find ( ( n ) => n . nodeName === 'body' ) as Element ;
212+ const select = body . childNodes . find ( ( n ) => ( n as Element ) . tagName === 'select' ) as Element ;
213+ const button = select . childNodes . find ( ( n ) => ( n as Element ) . tagName === 'button' ) as Element ;
214+ const selectedcontent = button . childNodes . find (
215+ ( n ) => ( n as Element ) . tagName === 'selectedcontent' ,
216+ ) as Element ;
217+
218+ expect ( selectedcontent . childNodes . length ) . toBeGreaterThan ( 0 ) ;
219+ expect ( ( selectedcontent . childNodes [ 0 ] as TextNode ) . value ) . toBe ( 'foo' ) ;
220+ } ) ;
221+ } ) ;
175222} ) ;
0 commit comments