Skip to content

Commit 86fc76f

Browse files
committed
adjust tests
1 parent 5f9cc83 commit 86fc76f

28 files changed

+4
-5463
lines changed

test/jasmine/assets/check_component.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
99
* but the test is that they may have been registered in any order
1010
*/
1111
module.exports = function checkComponent(Plotly) {
12-
describe('core (svg 2d, scatter) and registered (bar) traces and transforms', function() {
12+
describe('core (svg 2d, scatter) and registered (bar) traces', function() {
1313
var gd;
1414

1515
var mock = {
@@ -23,15 +23,6 @@ module.exports = function checkComponent(Plotly) {
2323
x: ['2001-01-01', '2002-01-01', '2003-01-01'],
2424
y: [1, 3, 5],
2525
type: 'bar',
26-
transforms: [{
27-
type: 'filter',
28-
operation: '<',
29-
target: 'y',
30-
value: '4',
31-
// need an explicit calendar, as filter uses a default of null
32-
// the rest of them get the default calendar filled in
33-
valuecalendar: 'nepali'
34-
}]
3526
}
3627
]
3728
};
@@ -59,7 +50,6 @@ module.exports = function checkComponent(Plotly) {
5950

6051
expect(nodes.size()).toEqual(1);
6152
expect(gd._fullData[1].xcalendar).toBe('gregorian');
62-
expect(gd._fullData[1].transforms[0].valuecalendar).toBe('nepali');
6353
});
6454
});
6555

test/jasmine/assets/mock_lists.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ var svgMockList = [
4444
['table_wrapped_birds', require('../../image/mocks/table_wrapped_birds.json')],
4545
['ternary_fill', require('../../image/mocks/ternary_fill.json')],
4646
['text_chart_arrays', require('../../image/mocks/text_chart_arrays.json')],
47-
['transforms', require('../../image/mocks/transforms.json')],
4847
['updatemenus', require('../../image/mocks/updatemenus.json')],
4948
['violin_side-by-side', require('../../image/mocks/violin_side-by-side.json')],
5049
['world-cals', require('../../image/mocks/world-cals.json')],

test/jasmine/bundle_tests/component_first_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Calendars = require('../../../lib/calendars');
66

77
var checkComponent = require('../assets/check_component');
88

9-
describe('Bundle with a component loaded before traces and transforms', function() {
9+
describe('Bundle with a component loaded before traces', function() {
1010
'use strict';
1111

1212
Plotly.register([Calendars, Filter, Scatter3d, Bar]);

test/jasmine/bundle_tests/component_last_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Calendars = require('../../../lib/calendars');
66

77
var checkComponent = require('../assets/check_component');
88

9-
describe('Bundle with a component loaded after traces and transforms', function() {
9+
describe('Bundle with a component loaded after traces', function() {
1010
'use strict';
1111

1212
Plotly.register([Bar, Scatter3d, Filter, Calendars]);

test/jasmine/bundle_tests/finance_test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ describe('Bundle with finance trace type', function() {
1414

1515
var mock = require('../../image/mocks/finance_style.json');
1616

17-
it('should not register transforms anymore', function() {
18-
var transformModules = Object.keys(Plots.transformsRegistry);
19-
20-
expect(transformModules).toEqual([]);
21-
});
22-
2317
it('should register the correct trace modules for the generated traces', function() {
2418
var traceModules = Object.keys(Plots.modules);
2519

test/jasmine/bundle_tests/plotschema_test.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ describe('plot schema', function() {
3636
});
3737
}
3838

39-
function assertTransformSchema(callback) {
40-
var transforms = plotSchema.transforms;
41-
42-
Object.keys(transforms).forEach(function(transformName) {
43-
Plotly.PlotSchema.crawl(transforms[transformName].attributes, callback, 0, transformName);
44-
});
45-
}
46-
4739
function assertLayoutSchema(callback) {
4840
Plotly.PlotSchema.crawl(plotSchema.layout.layoutAttributes, callback, 0, 'layout');
4941

@@ -60,7 +52,6 @@ describe('plot schema', function() {
6052
function assertPlotSchema(callback) {
6153
assertTraceSchema(callback);
6254
assertLayoutSchema(callback);
63-
assertTransformSchema(callback);
6455
}
6556

6657
it('all attributes should have a valid `valType`', function() {
@@ -271,13 +262,6 @@ describe('plot schema', function() {
271262
}
272263
});
273264

274-
assertTransformSchema(function(attr, attrName, attrs, level, attrString) {
275-
if(shouldHaveEditType(attr, attrName)) {
276-
expect(Lib.validate(attr.editType, editType.traces))
277-
.toBe(true, attrString + ': ' + JSON.stringify(attr.editType));
278-
}
279-
});
280-
281265
assertLayoutSchema(function(attr, attrName, attrs, level, attrString) {
282266
if(shouldHaveEditType(attr, attrName)) {
283267
expect(Lib.validate(attr.editType, editType.layout))
@@ -286,34 +270,6 @@ describe('plot schema', function() {
286270
});
287271
});
288272

289-
it('should work with registered transforms', function() {
290-
var valObjects = plotSchema.transforms.filter.attributes;
291-
var attrNames = Object.keys(valObjects);
292-
293-
['operation', 'value', 'target'].forEach(function(k) {
294-
expect(attrNames).toContain(k);
295-
});
296-
});
297-
298-
it('should work with registered transforms (2)', function() {
299-
var valObjects = plotSchema.transforms.groupby.attributes;
300-
var items = valObjects.styles.items || {};
301-
302-
expect(Object.keys(items)).toEqual(['style']);
303-
});
304-
305-
it('should work with registered components', function() {
306-
expect(plotSchema.traces.scatter.attributes.xcalendar.valType).toEqual('enumerated');
307-
expect(plotSchema.traces.scatter3d.attributes.zcalendar.valType).toEqual('enumerated');
308-
309-
expect(plotSchema.layout.layoutAttributes.calendar.valType).toEqual('enumerated');
310-
expect(plotSchema.layout.layoutAttributes.xaxis.calendar.valType).toEqual('enumerated');
311-
expect(plotSchema.layout.layoutAttributes.scene.xaxis.calendar.valType).toEqual('enumerated');
312-
313-
expect(plotSchema.transforms.filter.attributes.valuecalendar.valType).toEqual('enumerated');
314-
expect(plotSchema.transforms.filter.attributes.targetcalendar.valType).toEqual('enumerated');
315-
});
316-
317273
it('should list correct defs', function() {
318274
expect(plotSchema.defs.valObjects).toBeDefined();
319275

@@ -440,34 +396,6 @@ describe('getTraceValObject', function() {
440396
.toBe(surface.attributes.zcalendar);
441397
});
442398

443-
it('supports transform attributes', function() {
444-
var mockTrace = {transforms: [
445-
{type: 'filter'},
446-
{type: 'groupby'}
447-
]};
448-
449-
var filterAttrs = require('../../../lib/filter').attributes;
450-
expect(getTraceValObject(mockTrace, ['transforms', 0, 'operation']))
451-
.toBe(filterAttrs.operation);
452-
// check a component-provided attr
453-
expect(getTraceValObject(mockTrace, ['transforms', 0, 'valuecalendar']))
454-
.toBe(filterAttrs.valuecalendar);
455-
456-
expect(getTraceValObject(mockTrace, ['transforms', 1, 'styles', 13, 'value', 'line', 'color']))
457-
.toBe(require('../../../lib/groupby').attributes.styles.value);
458-
459-
[
460-
['transforms', 0],
461-
['transforms', 0, 'nameformat'],
462-
['transforms', 2, 'enabled'],
463-
['transforms', '0', 'operation']
464-
].forEach(function(attrArray) {
465-
expect(getTraceValObject(mockTrace, attrArray)).toBe(false, attrArray);
466-
});
467-
468-
expect(getTraceValObject({}, ['transforms', 0, 'operation'])).toBe(false);
469-
});
470-
471399
it('does not return attribute properties', function() {
472400
// it still returns the attribute itself - but maybe we should only do this
473401
// for valType: any? (or data_array/arrayOk with just an index)

test/jasmine/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func.defaultConfig = {
278278
//
279279
// Although not recommended, some tests "depend" on other
280280
// tests to pass (e.g. the Plotly.react tests check that
281-
// all available traces and transforms are tested). Tag these
281+
// all available traces are tested). Tag these
282282
// with @noCIdep, so that
283283
// - $ npm run test-jasmine -- tags=noCI,noCIdep
284284
// can pass.

test/jasmine/tests/animate_test.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -974,28 +974,6 @@ describe('animating scatter traces', function() {
974974
}).then(done, done.fail);
975975
});
976976

977-
it('computes calcdata correctly when transforms are present', function(done) {
978-
Plotly.newPlot(gd, {
979-
data: [{
980-
x: [1, 2, 3],
981-
y: [1, 2, 3],
982-
mode: 'markers',
983-
transforms: [{
984-
type: 'sort',
985-
target: [1, 3, 2]
986-
}]
987-
}],
988-
frames: [
989-
{name: 'frame1', data: [{y: [1, 2, 3]}]},
990-
{name: 'frame2', data: [{y: [3, 1, 2]}]}
991-
]
992-
}).then(function() {
993-
return Plotly.animate(gd, ['frame2'], {frame: {duration: 200, redraw: false}});
994-
}).then(function() {
995-
expect(gd.calcdata[0][0].y).toEqual(3);
996-
}).then(done, done.fail);
997-
});
998-
999977
it('@flaky should animate axis ranges using the less number of steps', function(done) {
1000978
// sanity-check that scatter points and bars are still there
1001979
function _assertNodeCnt() {

test/jasmine/tests/finance_test.js

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -55,67 +55,6 @@ describe('finance charts defaults:', function() {
5555
expect(out._fullData.length).toEqual(2);
5656
});
5757

58-
it('should not mutate user data', function() {
59-
var trace0 = Lib.extendDeep({}, mock0, {
60-
type: 'ohlc'
61-
});
62-
63-
var trace1 = Lib.extendDeep({}, mock1, {
64-
type: 'candlestick'
65-
});
66-
67-
var out = _supply([trace0, trace1]);
68-
expect(out.data[0]).toBe(trace0);
69-
expect(out.data[0].transforms).toBeUndefined();
70-
expect(out.data[1]).toBe(trace1);
71-
expect(out.data[1].transforms).toBeUndefined();
72-
73-
// ... and in an idempotent way
74-
75-
var out2 = _supply(out.data);
76-
expect(out2.data[0]).toBe(trace0);
77-
expect(out2.data[0].transforms).toBeUndefined();
78-
expect(out2.data[1]).toBe(trace1);
79-
expect(out2.data[1].transforms).toBeUndefined();
80-
});
81-
82-
it('should work with transforms', function() {
83-
var trace0 = Lib.extendDeep({}, mock1, {
84-
type: 'ohlc',
85-
transforms: [{
86-
type: 'filter'
87-
}]
88-
});
89-
90-
var trace1 = Lib.extendDeep({}, mock0, {
91-
type: 'candlestick',
92-
transforms: [{
93-
type: 'filter'
94-
}]
95-
});
96-
97-
var out = _supply([trace0, trace1]);
98-
99-
expect(out.data.length).toEqual(2);
100-
expect(out._fullData.length).toEqual(2);
101-
102-
var transformTypesIn = out.data.map(function(trace) {
103-
return trace.transforms.map(function(opts) {
104-
return opts.type;
105-
});
106-
});
107-
108-
expect(transformTypesIn).toEqual([ ['filter'], ['filter'] ]);
109-
110-
var transformTypesOut = out._fullData.map(function(fullTrace) {
111-
return fullTrace.transforms.map(function(opts) {
112-
return opts.type;
113-
});
114-
});
115-
116-
expect(transformTypesOut).toEqual([ ['filter'], ['filter'] ]);
117-
});
118-
11958
it('should not slice data arrays but record minimum supplied length', function() {
12059
function assertDataLength(trace, fullTrace, len) {
12160
expect(fullTrace.visible).toBe(true);
@@ -446,110 +385,6 @@ describe('finance charts calc', function() {
446385
expect(mapGet(out[1], 'empty')).toEqual(empties);
447386
});
448387

449-
it('should work with *filter* transforms', function() {
450-
var trace0 = Lib.extendDeep({}, mock1, {
451-
type: 'ohlc',
452-
tickwidth: 0.05,
453-
transforms: [{
454-
type: 'filter',
455-
operation: '>',
456-
target: 'open',
457-
value: 33
458-
}]
459-
});
460-
461-
var trace1 = Lib.extendDeep({}, mock1, {
462-
type: 'candlestick',
463-
transforms: [{
464-
type: 'filter',
465-
operation: '{}',
466-
target: 'x',
467-
value: ['2016-09-01', '2016-09-10']
468-
}]
469-
});
470-
471-
var out = _calc([trace0, trace1]);
472-
473-
expect(out.length).toEqual(2);
474-
475-
expect(out[0].x).toEqual([
476-
'2016-09-01', '2016-09-02', '2016-09-03', '2016-09-05', '2016-09-06', '2016-09-07', '2016-09-10'
477-
]);
478-
expect(out[0].open).toEqual([
479-
33.01, 33.31, 33.50, 34.12, 33.05, 33.31, 33.50
480-
]);
481-
482-
expect(out[1].x).toEqual([
483-
'2016-09-01', '2016-09-10'
484-
]);
485-
expect(out[1].close).toEqual([
486-
34.10, 33.70
487-
]);
488-
});
489-
490-
it('should work with *groupby* transforms (ohlc)', function() {
491-
var opts = {
492-
type: 'groupby',
493-
groups: ['b', 'b', 'b', 'a'],
494-
};
495-
496-
var trace0 = Lib.extendDeep({}, mock1, {
497-
type: 'ohlc',
498-
tickwidth: 0.05,
499-
transforms: [opts]
500-
});
501-
502-
var out = _calc([trace0]);
503-
504-
expect(out.length).toBe(2);
505-
506-
expect(out[0].name).toBe('b');
507-
expect(out[0].x).toEqual([
508-
'2016-09-01', '2016-09-02', '2016-09-03'
509-
]);
510-
expect(out[0].open).toEqual([
511-
33.01, 33.31, 33.5
512-
]);
513-
514-
expect(out[1].name).toBe('a');
515-
expect(out[1].x).toEqual([
516-
'2016-09-04'
517-
]);
518-
expect(out[1].open).toEqual([
519-
32.06
520-
]);
521-
});
522-
523-
it('should work with *groupby* transforms (candlestick)', function() {
524-
var opts = {
525-
type: 'groupby',
526-
groups: ['a', 'b', 'b', 'a'],
527-
};
528-
529-
var trace0 = Lib.extendDeep({}, mock1, {
530-
type: 'candlestick',
531-
transforms: [opts]
532-
});
533-
534-
var out = _calc([trace0]);
535-
536-
expect(out[0].name).toEqual('a');
537-
expect(out[0].x).toEqual([
538-
'2016-09-01', '2016-09-04'
539-
]);
540-
expect(out[0].open).toEqual([
541-
33.01, 32.06
542-
]);
543-
544-
expect(out[1].name).toEqual('b');
545-
expect(out[1].x).toEqual([
546-
'2016-09-02', '2016-09-03'
547-
]);
548-
expect(out[1].open).toEqual([
549-
33.31, 33.5
550-
]);
551-
});
552-
553388
it('should use the smallest trace minimum x difference to convert *tickwidth* to data coords for all traces attached to a given x-axis', function() {
554389
var trace0 = Lib.extendDeep({}, mock1, {
555390
type: 'ohlc'

0 commit comments

Comments
 (0)