@@ -120,10 +120,6 @@ describe('FeatureTrack', function() {
120120 } ) ;
121121
122122 it ( 'should render features with bigBed file' , function ( ) : any {
123- var featureClickedData = null ;
124- var featureClicked = function ( data ) {
125- featureClickedData = data ;
126- } ;
127123
128124 var p = pileup . create ( testDiv , {
129125 range : { contig : 'chr17' , start : 10000 , stop : 16500 } ,
@@ -140,91 +136,42 @@ describe('FeatureTrack', function() {
140136 data : pileup . formats . bigBed ( {
141137 url : '/test-data/chr17.22.10000-21000.bb' ,
142138 } ) ,
143- options : { onFeatureClicked : featureClicked } ,
144139 name : 'Features'
145140 }
146141 ]
147142 } ) ;
148143
149144
150- return waitFor ( ready , 2000 )
151- . then ( ( ) => {
145+ return waitFor ( ready , 2000 ) . then ( ( ) => {
152146 var features = drawnObjects ( testDiv , '.features' ) ;
153147 // there can be duplicates in the case where features are
154148 // overlapping more than one section of the canvas
155149 features = _ . uniq ( features , false , function ( x ) {
156150 return x . position . start ( ) ;
157151 } ) ;
158152
159- expect ( features ) . to . have . length ( 5 ) ;
160- expect ( features . map ( f => f . position . start ( ) ) ) . to . deep . equal (
161- [ 10000 , 10150 , 10400 , 16000 , 16180 ] ) ;
162-
163- // canvas height should be height of features that are overlapping
164- var height = yForRow ( 2 ) * window . devicePixelRatio ; // should be 2 rows
165-
166- features = testDiv . querySelector ( '.features' ) ;
167- expect ( features ) . to . not . be . null ;
168- if ( features != null ) {
169- expect ( features . style . height ) . to . equal ( `${ height } px` ) ;
170- }
171- // check clicking on feature in row 0
172- var canvasList = testDiv . getElementsByTagName ( 'canvas' ) ;
173- var canvas = canvasList [ 1 ] ;
174- expect ( featureClickedData ) . to . be . null ;
175- ReactTestUtils . Simulate . click ( canvas , { nativeEvent : { offsetX : 0 , offsetY : 10 } } ) ;
176- expect ( featureClickedData ) . to . not . be . null ;
177-
178- // check clicking on feature in row 1
179- featureClickedData = null ;
180- ReactTestUtils . Simulate . click ( canvas , { nativeEvent : { offsetX : 55 , offsetY : 10 } } ) ;
181- expect ( featureClickedData ) . to . not . be . null ;
182-
183- p . destroy ( ) ;
153+ expect ( features ) . to . have . length . at . least ( 2 ) ;
154+
155+ p . setRange ( { contig : 'chr22' , start : 20000 , stop : 21000 } ) ;
156+ } ) . delay ( 300 ) . then ( ( ) => {
157+ var features = drawnObjects ( testDiv , '.features' ) ;
158+ // there can be duplicates in the case where features are
159+ // overlapping more than one section of the canvas
160+ features = _ . uniq ( features , false , function ( x ) {
161+ return x . position . start ( ) ;
184162 } ) ;
185- } ) ;
186-
187- it ( 'should not exceed parent height limits ', function ( ) : any {
188- var p = pileup . create ( testDiv , {
189- range : { contig : 'chr22' , start : 20000 , stop : 21000 } ,
190- tracks : [
191- {
192- viz : pileup . viz . genome ( ) ,
193- data : pileup . formats . twoBit ( {
194- url : '/test-data/test.2bit'
195- } ) ,
196- isReference : true
197- } ,
198- {
199- viz : pileup . viz . features ( ) ,
200- data : pileup . formats . bigBed ( {
201- url : '/test-data/chr17.22.10000-21000.bb' ,
202- } ) ,
203- name : 'Features'
204- }
205- ]
206- } ) ;
207-
208- return waitFor ( ready , 2000 )
209- . then ( ( ) => {
210- var features = drawnObjects ( testDiv , '.features' ) ;
211- // there can be duplicates in the case where features are
212- // overlapping more than one section of the canvas
213- features = _ . uniq ( features , false , function ( x ) {
214- return x . position . start ( ) ;
215- } ) ;
216163
217- expect ( features ) . to . have . length ( 10 ) ;
164+ expect ( features ) . to . have . length ( 10 ) ;
218165
219- // canvas height should be maxed out
220- var expectedHeight = 150 * window . devicePixelRatio ;
221- var featureCanvas = testDiv . querySelector ( '.features' ) ;
222- expect ( featureCanvas ) . to . not . be . null ;
223- if ( featureCanvas != null ) {
224- expect ( featureCanvas . style . height ) . to . equal ( `${ expectedHeight } px` ) ;
225- }
226- p . destroy ( ) ;
227- } ) ;
166+ // canvas height should be maxed out, should not exceed parent height limits
167+ var expectedHeight = 150 * window . devicePixelRatio ;
168+ var featureCanvas = testDiv . querySelector ( '.features' ) ;
169+ expect ( featureCanvas ) . to . not . be . null ;
170+ if ( featureCanvas != null ) {
171+ expect ( featureCanvas . style . height ) . to . equal ( `${ expectedHeight } px` ) ;
172+ }
173+ p . destroy ( ) ;
174+ } ) ;
228175 } ) ;
229176 } ) ;
230177} ) ;
0 commit comments