@@ -84,6 +84,40 @@ describe('The Clip Object', () => {
8484 expect ( clip . track ?. id ) . toBe ( track . id ) ;
8585 } ) ;
8686
87+ it ( 'should remove event listeners on detach' , async ( ) => {
88+ const clip0 = new Clip ( { start : 0 , stop : 20 } ) ;
89+ const clip1 = new Clip ( { stop : 60 , start : 30 } ) ;
90+
91+ const composition = new Composition ( ) ;
92+ const track0 = composition . createTrack ( 'base' ) ;
93+ const track1 = composition . createTrack ( 'base' ) ;
94+
95+ await track0 . add ( clip0 ) ;
96+ await track0 . add ( clip1 ) ;
97+
98+ expect ( track0 . clips . length ) . toBe ( 2 ) ;
99+ expect ( track0 . clips [ 0 ] . start . frames ) . toBe ( 0 ) ;
100+ expect ( track0 . clips [ 0 ] . stop . frames ) . toBe ( 20 ) ;
101+
102+ expect ( track0 . clips [ 1 ] . start . frames ) . toBe ( 30 ) ;
103+ expect ( track0 . clips [ 1 ] . stop . frames ) . toBe ( 60 ) ;
104+
105+ clip1 . detach ( ) ;
106+
107+ expect ( track0 . clips . length ) . toBe ( 1 ) ;
108+
109+ await track1 . add ( clip1 ) ;
110+
111+ expect ( track1 . clips . length ) . toBe ( 1 ) ;
112+ expect ( track1 . clips [ 0 ] . start . frames ) . toBe ( 30 ) ;
113+ expect ( track1 . clips [ 0 ] . stop . frames ) . toBe ( 60 ) ;
114+
115+ clip1 . start = 10 ;
116+
117+ expect ( track1 . clips [ 0 ] . start . frames ) . toBe ( 10 ) ;
118+ expect ( track1 . clips [ 0 ] . stop . frames ) . toBe ( 60 ) ;
119+ } ) ;
120+
87121 it ( 'should be removable from the track' , async ( ) => {
88122 const clip1 = new Clip ( { stop : 900 , start : 570 } ) ;
89123
0 commit comments