@@ -133,12 +133,7 @@ describe('Test graph_obj', function () {
133133 var gd ;
134134
135135 beforeEach ( function ( ) {
136- gd = {
137- data : [
138- { 'name' : 'a' } ,
139- { 'name' : 'b' }
140- ]
141- } ;
136+ gd = { data : [ { 'name' : 'a' } , { 'name' : 'b' } ] } ;
142137 spyOn ( Plotly , 'redraw' ) ;
143138 spyOn ( Plotly , 'moveTraces' ) ;
144139 } ) ;
@@ -147,15 +142,15 @@ describe('Test graph_obj', function () {
147142 var expected = JSON . parse ( JSON . stringify ( gd ) ) ;
148143 expect ( function ( ) {
149144 Plotly . addTraces ( gd , 1 , 2 ) ;
150- } ) . toThrow ( new Error ( 'all values in traces array must be non-array objects' ) ) ;
145+ } ) . toThrowError ( Error , 'all values in traces array must be non-array objects' ) ;
151146
152147 expect ( function ( ) {
153148 Plotly . addTraces ( gd , [ { } , 4 ] , 2 ) ;
154- } ) . toThrow ( new Error ( 'all values in traces array must be non-array objects' ) ) ;
149+ } ) . toThrowError ( Error , 'all values in traces array must be non-array objects' ) ;
155150
156151 expect ( function ( ) {
157152 Plotly . addTraces ( gd , [ { } , [ ] ] , 2 ) ;
158- } ) . toThrow ( new Error ( 'all values in traces array must be non-array objects' ) ) ;
153+ } ) . toThrowError ( Error , 'all values in traces array must be non-array objects' ) ;
159154
160155 // make sure we didn't muck with gd.data if things failed!
161156 expect ( gd ) . toEqual ( expected ) ;
@@ -166,7 +161,7 @@ describe('Test graph_obj', function () {
166161
167162 expect ( function ( ) {
168163 Plotly . addTraces ( gd , [ { } , { } ] , 2 ) ;
169- } ) . toThrow ( new Error ( 'if indices is specified, traces.length must equal indices.length' ) ) ;
164+ } ) . toThrowError ( Error , 'if indices is specified, traces.length must equal indices.length' ) ;
170165
171166 } ) ;
172167
@@ -182,59 +177,41 @@ describe('Test graph_obj', function () {
182177 } ) ;
183178
184179 it ( 'should work when newIndices is undefined' , function ( ) {
185- var expectedData = [
186- { 'name' : 'a' } ,
187- { 'name' : 'b' } ,
188- { 'name' : 'c' } ,
189- { 'name' : 'd' }
190- ] ;
191-
192180 Plotly . addTraces ( gd , [ { 'name' : 'c' } , { 'name' : 'd' } ] ) ;
193- expect ( gd . data ) . toEqual ( expectedData ) ;
181+ expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
182+ expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
183+ expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
184+ expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
194185 expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
195186 expect ( Plotly . moveTraces ) . not . toHaveBeenCalled ( ) ;
196-
197187 } ) ;
198188
199189 it ( 'should work when newIndices is defined' , function ( ) {
200- var expectedData = [
201- { 'name' : 'a' } ,
202- { 'name' : 'b' } ,
203- { 'name' : 'c' } ,
204- { 'name' : 'd' }
205- ] ;
206-
207190 Plotly . addTraces ( gd , [ { 'name' : 'c' } , { 'name' : 'd' } ] , [ 1 , 3 ] ) ;
208- expect ( gd . data ) . toEqual ( expectedData ) ;
191+ expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
192+ expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
193+ expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
194+ expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
209195 expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
210196 expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ 1 , 3 ] ) ;
211197
212198 } ) ;
213199
214200 it ( 'should work when newIndices has negative indices' , function ( ) {
215- var expectedData = [
216- { 'name' : 'a' } ,
217- { 'name' : 'b' } ,
218- { 'name' : 'c' } ,
219- { 'name' : 'd' }
220- ] ;
221-
222201 Plotly . addTraces ( gd , [ { 'name' : 'c' } , { 'name' : 'd' } ] , [ - 3 , - 1 ] ) ;
223- expect ( gd . data ) . toEqual ( expectedData ) ;
202+ expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
203+ expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
204+ expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
205+ expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
224206 expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
225207 expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ - 3 , - 1 ] ) ;
226208
227209 } ) ;
228210
229211 it ( 'should work when newIndices is an integer' , function ( ) {
230- var expectedData = [
231- { 'name' : 'a' } ,
232- { 'name' : 'b' } ,
233- { 'name' : 'c' }
234- ] ;
235-
236212 Plotly . addTraces ( gd , { 'name' : 'c' } , 0 ) ;
237- expect ( gd . data ) . toEqual ( expectedData ) ;
213+ expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
214+ expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
238215 expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
239216 expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 1 ] , [ 0 ] ) ;
240217
0 commit comments