@@ -30,7 +30,7 @@ describe('calculated data and points', function() {
30
30
} ) ;
31
31
} ) ;
32
32
33
- xdescribe ( 'category ordering' , function ( ) {
33
+ describe ( 'category ordering' , function ( ) {
34
34
35
35
describe ( 'default category ordering reified' , function ( ) {
36
36
@@ -68,6 +68,8 @@ describe('calculated data and points', function() {
68
68
69
69
describe ( 'domain alphanumerical category ordering' , function ( ) {
70
70
71
+ // TODO augment test cases with selection on the DOM to ensure that ticks are there in proper order
72
+
71
73
it ( 'should output categories in ascending domain alphanumerical order' , function ( ) {
72
74
73
75
Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : {
@@ -82,7 +84,7 @@ describe('calculated data and points', function() {
82
84
expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 14 } ) ) ;
83
85
} ) ;
84
86
85
- fit ( 'should output categories in descending domain alphanumerical order' , function ( ) {
87
+ it ( 'should output categories in descending domain alphanumerical order' , function ( ) {
86
88
87
89
Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : {
88
90
type : 'category' ,
@@ -104,11 +106,11 @@ describe('calculated data and points', function() {
104
106
categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] // These must be ignored. Alternative: error?
105
107
} } ) ;
106
108
107
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 11 ) ;
108
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 13 ) ;
109
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( 15 ) ;
110
- expect ( gd . calcdata [ 0 ] [ 3 ] . y ) . toEqual ( 14 ) ;
111
- expect ( gd . calcdata [ 0 ] [ 4 ] . y ) . toEqual ( 12 ) ;
109
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 15 } ) ) ;
110
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 11 } ) ) ;
111
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 12 } ) ) ;
112
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 13 } ) ) ;
113
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 14 } ) ) ;
112
114
} ) ;
113
115
114
116
it ( 'should output categories in ascending domain alphanumerical order, excluding undefined' , function ( ) {
@@ -118,14 +120,14 @@ describe('calculated data and points', function() {
118
120
categorymode : 'category ascending'
119
121
} } ) ;
120
122
121
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 11 ) ;
122
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 15 ) ;
123
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( 14 ) ;
124
- expect ( gd . calcdata [ 0 ] [ 3 ] . y ) . toEqual ( 12 ) ;
123
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 15 } ) ) ;
124
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 12 } ) ) ;
125
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 13 } ) ) ;
126
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 14 } ) ) ;
125
127
} ) ;
126
128
} ) ;
127
129
128
- describe ( 'codomain numerical category ordering' , function ( ) {
130
+ xdescribe ( 'codomain numerical category ordering' , function ( ) {
129
131
130
132
it ( 'should output categories in ascending codomain numerical order' , function ( ) {
131
133
@@ -170,7 +172,7 @@ describe('calculated data and points', function() {
170
172
} ) ;
171
173
} ) ;
172
174
173
- describe ( 'explicit category ordering' , function ( ) {
175
+ fdescribe ( 'explicit category ordering' , function ( ) {
174
176
175
177
it ( 'should output categories in explicitly supplied order, independent of trace order' , function ( ) {
176
178
@@ -180,11 +182,11 @@ describe('calculated data and points', function() {
180
182
categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ]
181
183
} } ) ;
182
184
183
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 13 ) ;
184
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 11 ) ;
185
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( 14 ) ;
186
- expect ( gd . calcdata [ 0 ] [ 3 ] . y ) . toEqual ( 12 ) ;
187
- expect ( gd . calcdata [ 0 ] [ 4 ] . y ) . toEqual ( 15 ) ;
185
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 15 } ) ) ;
186
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 11 } ) ) ;
187
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 12 } ) ) ;
188
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 13 } ) ) ;
189
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 14 } ) ) ;
188
190
} ) ;
189
191
190
192
it ( 'should output categories in explicitly supplied order, independent of trace order, pruned' , function ( ) {
@@ -195,41 +197,74 @@ describe('calculated data and points', function() {
195
197
categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ]
196
198
} } ) ;
197
199
198
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 13 ) ;
199
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 14 ) ;
200
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( 15 ) ;
200
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 15 } ) ) ;
201
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( { x : false , y : false } ) ;
202
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 12 } ) ) ;
203
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( { x : false , y : false } ) ;
204
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 14 } ) ) ;
201
205
} ) ;
202
206
203
207
it ( 'should output categories in explicitly supplied order even if not all categories are present' , function ( ) {
204
208
205
209
Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : {
206
210
type : 'category' ,
207
211
categorymode : 'array' ,
208
- categorylist : [ 'y' , ' b', 'x' , 'a' , 'd' , 'z' , 'e' , 'c' ]
212
+ categorylist : [ 'b' , 'x' , 'a' , 'd' , 'z' , 'e' , 'c' ]
209
213
} } ) ;
210
214
211
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( null ) ;
212
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 13 ) ;
213
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( null ) ;
214
- expect ( gd . calcdata [ 0 ] [ 3 ] . y ) . toEqual ( 11 ) ;
215
- expect ( gd . calcdata [ 0 ] [ 4 ] . y ) . toEqual ( 14 ) ;
216
- expect ( gd . calcdata [ 0 ] [ 5 ] . y ) . toEqual ( null ) ;
217
- expect ( gd . calcdata [ 0 ] [ 6 ] . y ) . toEqual ( 12 ) ;
218
- expect ( gd . calcdata [ 0 ] [ 7 ] . y ) . toEqual ( 15 ) ;
215
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 15 } ) ) ;
216
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 11 } ) ) ;
217
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 12 } ) ) ;
218
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 13 } ) ) ;
219
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 14 } ) ) ;
219
220
} ) ;
220
221
221
- it ( 'should output categories in explicitly supplied order first, if not all categories are covered' , function ( ) {
222
+ it ( 'should output categories in explicitly supplied order even if some missing categories were at the beginning or end of categorylist' , function ( ) {
223
+
224
+ // TODO WARNING: THIS CASE *PASSES* BUT THE UNPOPULATED CATEGORIES AT THE EDGES AREN'T RENDERED IN THE DOM
225
+ // TODO enhance test cases with selection on the DOM to ensure that all unpopulated ticks are present
226
+
227
+ Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : {
228
+ type : 'category' ,
229
+ categorymode : 'array' ,
230
+ categorylist : [ 's' , 'y' , 'b' , 'x' , 'a' , 'd' , 'z' , 'e' , 'c' , 'q' , 'k' ]
231
+ } } ) ;
232
+
233
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 7 , y : 15 } ) ) ;
234
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 11 } ) ) ;
235
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 12 } ) ) ;
236
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 13 } ) ) ;
237
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 14 } ) ) ;
238
+ } ) ;
239
+
240
+ it ( 'should output categories in explicitly supplied order even if not all categories are present, and should interact with a null value orthogonally' , function ( ) {
241
+
242
+ Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , null , 12 , 13 , 14 ] } ] , { xaxis : {
243
+ type : 'category' ,
244
+ categorymode : 'array' ,
245
+ categorylist : [ 'b' , 'x' , 'a' , 'd' , 'z' , 'e' , 'c' ]
246
+ } } ) ;
247
+
248
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 15 } ) ) ;
249
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( { x : false , y : false } ) ;
250
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 12 } ) ) ;
251
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 13 } ) ) ;
252
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 14 } ) ) ;
253
+ } ) ;
254
+
255
+ fit ( 'should output categories in explicitly supplied order first, if not all categories are covered' , function ( ) {
222
256
223
257
Plotly . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : {
224
258
type : 'category' ,
225
259
categorymode : 'array' ,
226
260
categorylist : [ 'b' , 'a' , 'x' , 'c' ]
227
261
} } ) ;
228
262
229
- expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 13 ) ;
230
- expect ( gd . calcdata [ 0 ] [ 1 ] . y ) . toEqual ( 11 ) ;
231
- expect ( gd . calcdata [ 0 ] [ 2 ] . y ) . toEqual ( null ) ;
232
- expect ( gd . calcdata [ 0 ] [ 3 ] . y ) . toEqual ( 15 ) ;
263
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 15 } ) ) ;
264
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 11 } ) ) ;
265
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 12 } ) ) ;
266
+ expect ( gd . calcdata [ 0 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 13 } ) ) ;
267
+ expect ( gd . calcdata [ 0 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 14 } ) ) ;
233
268
234
269
// The order of the rest is unspecified, no need to check. Alternative: make _both_ categorymode and
235
270
// categories effective; categories would take precedence and the remaining items would be sorted
0 commit comments