Skip to content

Add global transforms config option #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions test/jasmine/tests/transforms_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,45 @@ describe('one-to-one transforms:', function() {
}, '- trace second');
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!
What do you think about one additional test that ensures transforms have access to fullTrace._input user data? Just in case someone other than yourself decides to refactor one day and accidentally breaks a bunch of userspace transforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 6af72d0

it('should pass correctly arguments to transform methods', function() {
var transformIn = { type: 'fake' };
var transformOut = {};

var dataIn = [{
transforms: [transformIn]
}];

var layout = {};

function assertSupplyDefaultsArgs(_transformIn, traceOut, _layout) {
expect(_transformIn).toBe(transformIn);
expect(_layout).toBe(layout);

return transformOut;
}

function assertTransformArgs(dataOut, opts) {
expect(dataOut[0]._input).toBe(dataIn[0]);
expect(opts.transform).toBe(transformOut);
expect(opts.fullTrace._input).toBe(dataIn[0]);
expect(opts.layout).toBe(layout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


return dataOut;
}

var fakeTransformModule = {
moduleType: 'transform',
name: 'fake',
attributes: {},
supplyDefaults: assertSupplyDefaultsArgs,
transform: assertTransformArgs
};

Plotly.register(fakeTransformModule);
Plots.supplyDataDefaults(dataIn, [], layout);
delete Plots.transformsRegistry.fake;
});

it('supplyDataDefaults should apply the transform while', function() {
var dataIn = [{
x: [-2, -2, 1, 2, 3],
Expand Down