/
2ndYaxisTest.js
352 lines (320 loc) · 13.7 KB
/
2ndYaxisTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var BeakerXPageObject = require('../beakerx.po.js');
var beakerxPO;
describe('2nd Y Axis js', function () {
beforeAll(function () {
beakerxPO = new BeakerXPageObject();
beakerxPO.runNotebookByUrl('/test/ipynb/groovy/2ndYaxisTest.ipynb');
}, 2);
afterAll(function () {
beakerxPO.closeAndHaltNotebook();
});
function getAttrFor2ndElement(dtContainer, slctr, index, attr){
return dtContainer.$('g#i' + index + ' ' + slctr + '#i' + index + '_1').getAttribute(attr);
}
function expectToEqualsElements(dtContainer, slctr, attr, i0, i1){
var g0_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i0)?0:i0, attr);
var g1_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i1)?1:i1, attr);
expect(g1_elem2).toEqual(g0_elem2);
}
function expect2ndYElementIsHigher(dtContainer, slctr, attr, i0, i1){
var g0_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i0)?0:i0, attr);
var g1_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i1)?1:i1, attr);
expect(g1_elem2).toBeLessThan(g0_elem2);
}
function expect2ndYElementIsLower(dtContainer, slctr, attr, i0, i1){
var g0_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i0)?0:i0, attr);
var g1_elem2 = getAttrFor2ndElement(dtContainer, slctr, (!i1)?1:i1, attr);
expect(g1_elem2).toBeGreaterThan(g0_elem2);
}
describe('Default scale (lines)', function(){
var dtContainer;
it('Plot has 2 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(0);
expect(dtContainer.$$('g#maing > g').length).toEqual(2);
});
it('Line for 2nd Y axis is under Line for 1st Y axis', function(){
expect2ndYElementIsLower(dtContainer, 'circle', 'cy');
});
});
describe('The same scale (lines)', function(){
var dtContainer;
it('Plot has 2 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(1);
expect(dtContainer.$$('g#maing > g').length).toEqual(2);
});
it('Line for 2nd and 1st Y axises have the same 2nd point', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy');
});
});
describe('2nd YAxis is zoomed (lines)', function(){
var dtContainer;
it('Plot has 2 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(2);
expect(dtContainer.$$('g#maing > g').length).toEqual(2);
});
it('Line for 2nd Y axis is over Line for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'circle', 'cy');
});
});
describe('Default scale (category bars)', function(){
var dtContainer;
it('Plot has 16 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(3);
expect(dtContainer.$$('g#maing rect').length).toEqual(16);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y', 0, 2);
expectToEqualsElements(dtContainer, 'rect', 'y', 1, 3);
});
});
describe('The same scale (category bars)', function(){
var dtContainer;
it('Plot has 16 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(4);
expect(dtContainer.$$('g#maing rect').length).toEqual(16);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y', 0, 2);
expectToEqualsElements(dtContainer, 'rect', 'y', 1, 3);
});
});
describe('2nd YAxis is zoomed (category bars)', function(){
var dtContainer;
it('Plot has 16 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(5);
expect(dtContainer.$$('g#maing rect').length).toEqual(16);
});
it('Bar for 2nd Y axis is higher than Bar for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'rect', 'y', 0, 2);
expect2ndYElementIsHigher(dtContainer, 'rect', 'y', 1, 3);
});
});
describe('Default scale (stems)', function(){
var dtContainer;
it('Plot has 20 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(6);
expect(dtContainer.$$('g#maing line').length).toEqual(20);
});
it('Stems for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'line', 'y2');
});
});
describe('The same scale (stems)', function(){
var dtContainer;
it('Plot has 20 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(7);
expect(dtContainer.$$('g#maing line').length).toEqual(20);
});
it('Stems for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'line', 'y2');
});
});
describe('2nd YAxis is zoomed (stems)', function(){
var dtContainer;
it('Plot has 20 lines', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(8);
expect(dtContainer.$$('g#maing line').length).toEqual(20);
});
it('Stem for 2nd Y axis is higher than Stem for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'line', 'y2');
});
});
describe('Default scale (bars)', function(){
var dtContainer;
it('Plot has 10 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(9);
expect(dtContainer.$$('g#maing rect').length).toEqual(10);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y');
});
});
describe('The same scale (bars)', function(){
var dtContainer;
it('Plot has 10 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(10);
expect(dtContainer.$$('g#maing rect').length).toEqual(10);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y');
});
});
describe('2nd YAxis is zoomed (bars)', function(){
var dtContainer;
it('Plot has 10 bars', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(11);
expect(dtContainer.$$('g#maing rect').length).toEqual(10);
});
it('Bar for 2nd Y axis is higher than Bar for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'rect', 'y');
});
});
describe('Default scale (points)', function(){
var dtContainer;
it('Plot has 10 points', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(12);
expect(dtContainer.$$('g#maing circle').length).toEqual(10);
});
it('Point for 2nd Y axis is higher than Point for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'circle', 'cy');
});
});
describe('The same scale (points)', function(){
var dtContainer;
it('Plot has 10 points', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(13);
expect(dtContainer.$$('g#maing circle').length).toEqual(10);
});
it('Points for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy');
});
});
describe('2nd YAxis is zoomed (points)', function(){
var dtContainer;
it('Plot has 10 points', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(14);
expect(dtContainer.$$('g#maing circle').length).toEqual(10);
});
it('Point for 2nd Y axis is higher than Point for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'circle', 'cy');
});
});
describe('Default scale (areas)', function(){
var dtContainer;
it('Plot has 2 areas', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(15);
expect(dtContainer.$$('g#maing polygon').length).toEqual(2);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y');
});
});
describe('The same scale (areas)', function(){
var dtContainer;
it('Plot has 2 areas', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(16);
expect(dtContainer.$$('g#maing polygon').length).toEqual(2);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y');
});
});
describe('2nd YAxis is zoomed (areas)', function(){
var dtContainer;
it('Plot has 2 areas', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(17);
expect(dtContainer.$$('g#maing polygon').length).toEqual(2);
});
it('Bar for 2nd Y axis is higher than Bar for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'rect', 'y');
});
});
function expectToEqualsAllElements(dtContainer, i0, i1, i2, i3){
var g0_elem2 = getAttrFor2ndElement(dtContainer, 'circle', i0, 'cy');
var g1_elem2 = getAttrFor2ndElement(dtContainer, 'circle', i1, 'cy');
var g2_elem2 = getAttrFor2ndElement(dtContainer, 'rect', i2, 'y');
var g3_elem2 = getAttrFor2ndElement(dtContainer, 'line', i3, 'y2');
expect(g0_elem2).toEqual(g1_elem2);
expect(g0_elem2).toEqual(g2_elem2);
expect(g0_elem2).toEqual(g3_elem2);
}
describe('Default scale (lines, points, bars and stems)', function(){
var dtContainer;
it('Plot has lines, points, bars and stems', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(18);
expect(dtContainer.$$('g#maing path.plot-line').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-point').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-bar').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-stem').length).toBeGreaterThan(1);
});
it('Line, Point, Bar and Stem for 1st Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 0, 1, 2, 3);
});
it('Line, Point, Bar and Stem for 2nd Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 4, 5, 6, 7);
});
it('Line for 2nd and 1st Y axises have the same 2nd point', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy', 0, 4);
});
it('Points for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy', 1, 5);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y', 2, 6);
});
it('Stems for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'line', 'y2', 3, 7);
});
});
describe('The same scale (lines, points, bars and stems)', function(){
var dtContainer;
it('Plot has lines, points, bars and stems', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(19);
expect(dtContainer.$$('g#maing path.plot-line').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-point').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-bar').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-stem').length).toBeGreaterThan(1);
});
it('Line, Point, Bar and Stem for 1st Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 0, 1, 2, 3);
});
it('Line, Point, Bar and Stem for 2nd Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 4, 5, 6, 7);
});
it('Line for 2nd and 1st Y axises have the same 2nd point', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy', 0, 4);
});
it('Points for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'circle', 'cy', 1, 5);
});
it('Bars for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'rect', 'y', 2, 6);
});
it('Stems for 2nd and 1st Y axises have the same height', function(){
expectToEqualsElements(dtContainer, 'line', 'y2', 3, 7);
});
});
describe('2nd YAxis is zoomed (lines, points, bars and stems)', function(){
var dtContainer;
it('Plot has lines, points, bars and stems', function(){
dtContainer = beakerxPO.runCellToGetDtContainer(20);
expect(dtContainer.$$('g#maing path.plot-line').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-point').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-bar').length).toBeGreaterThan(1);
expect(dtContainer.$$('g#maing g.plot-stem').length).toBeGreaterThan(1);
});
it('Line, Point, Bar and Stem for 1st Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 0, 1, 2, 3);
});
it('Line, Point, Bar and Stem for 2nd Y axis have the same y position', function(){
expectToEqualsAllElements(dtContainer, 4, 5, 6, 7);
});
it('Line for 2nd Y axis is over Line for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'circle', 'cy', 0, 4);
});
it('Point for 2nd Y axis is higher than Point for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'circle', 'cy', 1, 5);
});
it('Bar for 2nd Y axis is higher than Bar for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'rect', 'y', 2, 6);
});
it('Stem for 2nd Y axis is higher than Stem for 1st Y axis', function(){
expect2ndYElementIsHigher(dtContainer, 'line', 'y2', 3, 7);
});
});
});