@@ -126,14 +126,25 @@ test("the add-media example carries every attribute Studio's drop writes", async
126126 }
127127} ) ;
128128
129+ const CLIP_ATTRS = [ "id=" , 'class="clip"' , "data-start" , "data-track-index" ] ;
130+
131+ const mediaExample = ( section , tag ) =>
132+ section . match ( new RegExp ( `<${ tag } [\\s\\S]*?</${ tag } >` ) ) ?. [ 0 ] ?? "" ;
133+
134+ const assertNoAuthoredDuration = ( example , tag ) => {
135+ assert . ok ( example , `no <${ tag } > example` ) ;
136+ assert . doesNotMatch ( example , / d a t a - d u r a t i o n / , `${ tag } example must not author a duration` ) ;
137+ } ;
138+
139+ const assertHasAttrs = ( example , tag , attrs ) => {
140+ for ( const attr of attrs ) assert . ok ( example . includes ( attr ) , `${ tag } example lacks ${ attr } ` ) ;
141+ } ;
142+
129143test ( "the video and audio add-media examples carry no data-duration and keep the clip attributes" , async ( ) => {
130144 const { section } = await addMediaSection ( ) ;
131145 for ( const tag of [ "video" , "audio" ] ) {
132- const example = section . match ( new RegExp ( `<${ tag } [\\s\\S]*?</${ tag } >` ) ) ?. [ 0 ] ?? "" ;
133- assert . ok ( example , `no <${ tag } > example` ) ;
134- assert . doesNotMatch ( example , / d a t a - d u r a t i o n / , `${ tag } example must not author a duration` ) ;
135- for ( const attr of [ "id=" , 'class="clip"' , "data-start" , "data-track-index" ] ) {
136- assert . ok ( example . includes ( attr ) , `${ tag } example lacks ${ attr } ` ) ;
137- }
146+ const example = mediaExample ( section , tag ) ;
147+ assertNoAuthoredDuration ( example , tag ) ;
148+ assertHasAttrs ( example , tag , CLIP_ATTRS ) ;
138149 }
139150} ) ;
0 commit comments