@@ -42,6 +42,23 @@ describe('select box and lasso', function() {
4242        expect ( actual . y ) . toBeCloseToArray ( expected . y ,  PRECISION ) ; 
4343    } 
4444
45+     function  assertEventData ( actual ,  expected ,  msg )  { 
46+         expect ( actual . length ) . toBe ( expected . length ,  msg  +  ' same number of pts' ) ; 
47+ 
48+         expected . forEach ( function ( e ,  i )  { 
49+             var  a  =  actual [ i ] ; 
50+             var  m  =  msg  +  ' (pt '  +  i  +  ')' ; 
51+ 
52+             expect ( a . data ) . toBeDefined ( m  +  ' has data ref' ) ; 
53+             expect ( a . fullData ) . toBeDefined ( m  +  ' has fullData ref' ) ; 
54+             expect ( Object . keys ( a ) . length  -  2 ) . toBe ( Object . keys ( e ) . length ,  m  +  ' has correct number of keys' ) ; 
55+ 
56+             Object . keys ( e ) . forEach ( function ( k )  { 
57+                 expect ( a [ k ] ) . toBe ( e [ k ] ,  m  +  ' '  +  k ) ; 
58+             } ) ; 
59+         } ) ; 
60+     } 
61+ 
4562    describe ( 'select elements' ,  function ( )  { 
4663        var  mockCopy  =  Lib . extendDeep ( { } ,  mock ) ; 
4764        mockCopy . layout . dragmode  =  'select' ; 
@@ -143,6 +160,10 @@ describe('select box and lasso', function() {
143160    describe ( 'select events' ,  function ( )  { 
144161        var  mockCopy  =  Lib . extendDeep ( { } ,  mock ) ; 
145162        mockCopy . layout . dragmode  =  'select' ; 
163+         mockCopy . data [ 0 ] . ids  =  mockCopy . data [ 0 ] . x 
164+             . map ( function ( v )  {  return  'id-'  +  v ;  } ) ; 
165+         mockCopy . data [ 0 ] . customdata  =  mockCopy . data [ 0 ] . y 
166+             . map ( function ( v )  {  return  'customdata-'  +  v ;  } ) ; 
146167
147168        var  gd ; 
148169        beforeEach ( function ( done )  { 
@@ -175,38 +196,41 @@ describe('select box and lasso', function() {
175196            drag ( selectPath ) ; 
176197
177198            expect ( selectingCnt ) . toEqual ( 1 ,  'with the correct selecting count' ) ; 
178-             expect ( selectingData . points ) . toEqual ( [ { 
199+             assertEventData ( selectingData . points ,   [ { 
179200                curveNumber : 0 , 
180201                pointNumber : 0 , 
181202                x : 0.002 , 
182203                y : 16.25 , 
183-                 id : undefined 
204+                 id : 'id-0.002' , 
205+                 customdata : 'customdata-16.25' 
184206            } ,  { 
185207                curveNumber : 0 , 
186208                pointNumber : 1 , 
187209                x : 0.004 , 
188210                y : 12.5 , 
189-                 id : undefined 
190-             } ] ,  'with the correct selecting points' ) ; 
211+                 id : 'id-0.004' , 
212+                 customdata : 'customdata-12.5' 
213+             } ] ,  'with the correct selecting points (1)' ) ; 
191214            assertRange ( selectingData . range ,  { 
192215                x : [ 0.002000 ,  0.0046236 ] , 
193216                y : [ 0.10209191961595454 ,  24.512223978291406 ] 
194217            } ,  'with the correct selecting range' ) ; 
195- 
196218            expect ( selectedCnt ) . toEqual ( 1 ,  'with the correct selected count' ) ; 
197-             expect ( selectedData . points ) . toEqual ( [ { 
219+             assertEventData ( selectedData . points ,   [ { 
198220                curveNumber : 0 , 
199221                pointNumber : 0 , 
200222                x : 0.002 , 
201223                y : 16.25 , 
202-                 id : undefined 
224+                 id : 'id-0.002' , 
225+                 customdata : 'customdata-16.25' 
203226            } ,  { 
204227                curveNumber : 0 , 
205228                pointNumber : 1 , 
206229                x : 0.004 , 
207230                y : 12.5 , 
208-                 id : undefined 
209-             } ] ,  'with the correct selected points' ) ; 
231+                 id : 'id-0.004' , 
232+                 customdata : 'customdata-12.5' 
233+             } ] ,  'with the correct selected points (2)' ) ; 
210234            assertRange ( selectedData . range ,  { 
211235                x : [ 0.002000 ,  0.0046236 ] , 
212236                y : [ 0.10209191961595454 ,  24.512223978291406 ] 
@@ -255,22 +279,20 @@ describe('select box and lasso', function() {
255279            drag ( lassoPath ) ; 
256280
257281            expect ( selectingCnt ) . toEqual ( 3 ,  'with the correct selecting count' ) ; 
258-             expect ( selectingData . points ) . toEqual ( [ { 
282+             assertEventData ( selectingData . points ,   [ { 
259283                curveNumber : 0 , 
260284                pointNumber : 10 , 
261285                x : 0.099 , 
262-                 y : 2.75 , 
263-                 id : undefined 
264-             } ] ,  'with the correct selecting points' ) ; 
286+                 y : 2.75 
287+             } ] ,  'with the correct selecting points (1)' ) ; 
265288
266289            expect ( selectedCnt ) . toEqual ( 1 ,  'with the correct selected count' ) ; 
267-             expect ( selectedData . points ) . toEqual ( [ { 
290+             assertEventData ( selectedData . points ,   [ { 
268291                curveNumber : 0 , 
269292                pointNumber : 10 , 
270293                x : 0.099 , 
271294                y : 2.75 , 
272-                 id : undefined 
273-             } ] ,  'with the correct selected points' ) ; 
295+             } ] ,  'with the correct selected points (2)' ) ; 
274296
275297            doubleClick ( 250 ,  200 ) . then ( function ( )  { 
276298                expect ( doubleClickData ) . toBe ( null ,  'with the correct deselect data' ) ; 
0 commit comments