Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7e41625
Removed reference to Plotly
mdtusz Jan 8, 2016
b716568
Removed more references to Plotly
mdtusz Jan 11, 2016
d639a93
Change `module` to `_module`
mdtusz Jan 11, 2016
356d0af
Change `Plotly.Lib` to `Lib`
mdtusz Jan 11, 2016
7a22cff
Modify trace modules to all follow the same format, exporing `plot`
mdtusz Jan 12, 2016
2ac3605
Modify trace modules to work with registry
mdtusz Jan 13, 2016
6e53762
Update tests to require trace modules directly
mdtusz Jan 13, 2016
46b83d8
Modify index and plotly to have register func and traces registered
mdtusz Jan 13, 2016
23519f0
Require pie trace module directly
mdtusz Jan 13, 2016
71db785
Plot register function warns instead of throwing error
mdtusz Jan 13, 2016
06640b4
Update plotting calls to work agnostically using registered modules
mdtusz Jan 13, 2016
4507ec5
Fix eslint warnings for multiple var declarations
mdtusz Jan 13, 2016
6bd4c5b
Removed reference to Plotly
mdtusz Jan 8, 2016
b4793c1
Removed more references to Plotly
mdtusz Jan 11, 2016
48b3803
Change `module` to `_module`
mdtusz Jan 11, 2016
5a2da5c
Change `Plotly.Lib` to `Lib`
mdtusz Jan 11, 2016
4fe8440
Modify trace modules to all follow the same format, exporing `plot`
mdtusz Jan 12, 2016
e46373e
Modify trace modules to work with registry
mdtusz Jan 13, 2016
a7fda91
Update tests to require trace modules directly
mdtusz Jan 13, 2016
43156a3
Modify index and plotly to have register func and traces registered
mdtusz Jan 13, 2016
03232e0
Require pie trace module directly
mdtusz Jan 13, 2016
28def12
Plot register function warns instead of throwing error
mdtusz Jan 13, 2016
f831b66
Update plotting calls to work agnostically using registered modules
mdtusz Jan 13, 2016
4994256
Fix eslint warnings for multiple var declarations
mdtusz Jan 13, 2016
6dd9a41
Fix undefined reference
mdtusz Jan 13, 2016
823ae72
Merge branch 'agnostic-geo-trace' of github.com:plotly/plotly.js into…
mdtusz Jan 13, 2016
75dc282
Change fields used by module registry
mdtusz Jan 14, 2016
b8864eb
Require styleOne directly
mdtusz Jan 14, 2016
5f26169
Use Object.keys instead of for-in
mdtusz Jan 14, 2016
a693bb2
Change register function and add test
mdtusz Jan 14, 2016
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
Prev Previous commit
Next Next commit
Update tests to require trace modules directly
  • Loading branch information
mdtusz committed Jan 13, 2016
commit 6e53762d49dc76aa5a3e79f193cc6e8f037f690a
3 changes: 1 addition & 2 deletions test/jasmine/tests/choropleth_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
var Plotly = require('@src/plotly');
var Choropleth = require('@src/traces/choropleth');


describe('Test choropleth', function() {
'use strict';

var Choropleth = Plotly.Choropleth;

describe('supplyDefaults', function() {
var traceIn,
traceOut;
Expand Down
6 changes: 4 additions & 2 deletions test/jasmine/tests/colorscale_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var Plotly = require('@src/plotly');
var Colorscale = require('@src/components/colorscale');
var Heatmap = require('@src/traces/heatmap');
var Scatter = require('@src/traces/scatter');


describe('Test colorscale:', function() {
Expand Down Expand Up @@ -191,7 +193,7 @@ describe('Test colorscale:', function() {
var traceIn, traceOut;

function coerce(attr, dflt) {
return Plotly.Lib.coerce(traceIn, traceOut, Plotly.Heatmap.attributes, attr, dflt);
return Plotly.Lib.coerce(traceIn, traceOut, Heatmap.attributes, attr, dflt);
}

beforeEach(function() {
Expand Down Expand Up @@ -261,7 +263,7 @@ describe('Test colorscale:', function() {
var traceIn, traceOut;

function coerce(attr, dflt) {
return Plotly.Lib.coerce(traceIn, traceOut, Plotly.Scatter.attributes, attr, dflt);
return Plotly.Lib.coerce(traceIn, traceOut, Scatter.attributes, attr, dflt);
}

beforeEach(function() {
Expand Down
7 changes: 4 additions & 3 deletions test/jasmine/tests/contour_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Plotly = require('@src/plotly');
var Plots = require('@src/plots/plots');
var Contour = require('@src/traces/contour');


describe('Test contour', function() {
Expand All @@ -10,10 +11,10 @@ describe('Test contour', function() {

var defaultColor = '#444',
layout = {
font: Plotly.Plots.layoutAttributes.font
font: Plots.layoutAttributes.font
};

var supplyDefaults = Plotly.Contour.supplyDefaults;
var supplyDefaults = Contour.supplyDefaults;

beforeEach(function() {
traceOut = {};
Expand Down
10 changes: 5 additions & 5 deletions test/jasmine/tests/heatmap_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Plotly = require('@src/plotly');
var Heatmap = require('@src/traces/heatmap');
var convertColumnXYZ = require('@src/traces/heatmap/convert_column_xyz');
var Heatmap = require('@src/traces/heatmap');
var Plots = require('@src/plots/plots');


describe('Test heatmap', function() {
Expand All @@ -12,7 +12,7 @@ describe('Test heatmap', function() {

var defaultColor = '#444',
layout = {
font: Plotly.Plots.layoutAttributes.font
font: Plots.layoutAttributes.font
};

var supplyDefaults = Heatmap.supplyDefaults;
Expand Down Expand Up @@ -44,13 +44,13 @@ describe('Test heatmap', function() {
type: 'heatmap',
z: [[1, 2], []]
};
traceOut = Plotly.Plots.supplyDataDefaults(traceIn, 0, layout);
traceOut = Plots.supplyDataDefaults(traceIn, 0, layout);

traceIn = {
type: 'heatmap',
z: [[], [1, 2], [1, 2, 3]]
};
traceOut = Plotly.Plots.supplyDataDefaults(traceIn, 0, layout);
traceOut = Plots.supplyDataDefaults(traceIn, 0, layout);
expect(traceOut.visible).toBe(true);
expect(traceOut.visible).toBe(true);
});
Expand Down
28 changes: 16 additions & 12 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
var Plotly = require('@src/plotly');
var Plots = require('@src/plots/plots');
var Scatter = require('@src/traces/scatter');
var Bar = require('@src/traces/bar');
var Legend = require('@src/components/legend');

describe('Test graph_obj', function() {
'use strict';

describe('Plotly.restyle', function() {
beforeEach(function() {
spyOn(Plotly.Plots, 'previousPromises');
spyOn(Plotly, 'plot');
spyOn(Plotly.Scatter, 'arraysToCalcdata');
spyOn(Plotly.Bar, 'arraysToCalcdata');
spyOn(Plotly.Plots, 'style');
spyOn(Plotly.Legend, 'draw');
spyOn(Plots, 'previousPromises');
spyOn(Scatter, 'arraysToCalcdata');
spyOn(Bar, 'arraysToCalcdata');
spyOn(Plots, 'style');
spyOn(Legend, 'draw');
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting.

These methods are being spyOn'ed correctly? Is it become src/plots/plots.js still requires src/plotly.js ?

});

function mockDefaultsAndCalc(gd) {
Plotly.Plots.supplyDefaults(gd);
Plots.supplyDefaults(gd);
gd.calcdata = gd._fullData.map(function(trace) {
return [{x: 1, y: 1, trace: trace}];
});
Expand All @@ -27,9 +31,9 @@ describe('Test graph_obj', function() {
};
mockDefaultsAndCalc(gd);
Plotly.restyle(gd, {'marker.color': 'red'});
expect(Plotly.Scatter.arraysToCalcdata).toHaveBeenCalled();
expect(Plotly.Bar.arraysToCalcdata).not.toHaveBeenCalled();
expect(Plotly.Plots.style).toHaveBeenCalled();
expect(Scatter.arraysToCalcdata).toHaveBeenCalled();
expect(Bar.arraysToCalcdata).not.toHaveBeenCalled();
expect(Plots.style).toHaveBeenCalled();
expect(Plotly.plot).not.toHaveBeenCalled();
// "docalc" deletes gd.calcdata - make sure this didn't happen
expect(gd.calcdata).toBeDefined();
Expand All @@ -42,9 +46,9 @@ describe('Test graph_obj', function() {
};
mockDefaultsAndCalc(gd);
Plotly.restyle(gd, {'marker.color': 'red'});
expect(Plotly.Scatter.arraysToCalcdata).not.toHaveBeenCalled();
expect(Plotly.Bar.arraysToCalcdata).toHaveBeenCalled();
expect(Plotly.Plots.style).toHaveBeenCalled();
expect(Scatter.arraysToCalcdata).not.toHaveBeenCalled();
expect(Bar.arraysToCalcdata).toHaveBeenCalled();
expect(Plots.style).toHaveBeenCalled();
expect(Plotly.plot).not.toHaveBeenCalled();
expect(gd.calcdata).toBeDefined();
});
Expand Down
72 changes: 36 additions & 36 deletions test/jasmine/tests/plots_test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
var Plotly = require('@src/plotly');
var Plots = require('@src/plots/plots');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');


describe('Test Plotly.Plots', function() {

describe('Test Plots', function() {
'use strict';

describe('Plotly.Plots.supplyLayoutGlobalDefaults should', function() {
describe('Plots.supplyLayoutGlobalDefaults should', function() {
var layoutIn,
layoutOut,
expected;

var supplyLayoutDefaults = Plotly.Plots.supplyLayoutGlobalDefaults;
var supplyLayoutDefaults = Plots.supplyLayoutGlobalDefaults;

beforeEach(function() {
layoutOut = {};
Expand Down Expand Up @@ -65,8 +67,8 @@ describe('Test Plotly.Plots', function() {

});

describe('Plotly.Plots.supplyDataDefaults', function() {
var supplyDataDefaults = Plotly.Plots.supplyDataDefaults,
describe('Plots.supplyDataDefaults', function() {
var supplyDataDefaults = Plots.supplyDataDefaults,
layout = {};

var traceIn, traceOut;
Expand Down Expand Up @@ -98,8 +100,8 @@ describe('Test Plotly.Plots', function() {
});
});

describe('Plotly.Plots.getSubplotIds', function() {
var getSubplotIds = Plotly.Plots.getSubplotIds;
describe('Plots.getSubplotIds', function() {
var getSubplotIds = Plots.getSubplotIds;
var layout;

it('returns scene ids', function() {
Expand Down Expand Up @@ -143,8 +145,8 @@ describe('Test Plotly.Plots', function() {
});
});

describe('Plotly.Plots.getSubplotIdsInData', function() {
var getSubplotIdsInData = Plotly.Plots.getSubplotIdsInData;
describe('Plots.getSubplotIdsInData', function() {
var getSubplotIdsInData = Plots.getSubplotIdsInData;

var ids, data;

Expand Down Expand Up @@ -173,11 +175,11 @@ describe('Test Plotly.Plots', function() {

});

describe('Plotly.Plots.register, getModule, and traceIs', function() {
describe('Plots.register, getModule, and traceIs', function() {
beforeEach(function() {
this.modulesKeys = Object.keys(Plotly.Plots.modules);
this.allTypesKeys = Object.keys(Plotly.Plots.allTypes);
this.allCategoriesKeys = Object.keys(Plotly.Plots.allCategories);
this.modulesKeys = Object.keys(Plots.modules);
this.allTypesKeys = Object.keys(Plots.allTypes);
this.allCategoriesKeys = Object.keys(Plots.allCategories);

this.fakeModule = {
calc: function() { return 42; },
Expand All @@ -187,7 +189,7 @@ describe('Test Plotly.Plots', function() {
plot: function() { throw new Error('nope!'); }
};

Plotly.Plots.register(this.fakeModule, 'newtype', ['red', 'green']);
Plots.register(this.fakeModule, 'newtype', ['red', 'green']);

spyOn(console, 'warn');
});
Expand All @@ -199,52 +201,50 @@ describe('Test Plotly.Plots', function() {
});
}

revertObj(Plotly.Plots.modules, this.modulesKeys);
revertObj(Plotly.Plots.allTypes, this.allTypesKeys);
revertObj(Plotly.Plots.allCategories, this.allCategoriesKeys);
revertObj(Plots.modules, this.modulesKeys);
revertObj(Plots.allTypes, this.allTypesKeys);
revertObj(Plots.allCategories, this.allCategoriesKeys);
});

it('should error on attempts to reregister a type', function() {
var fm2 = this.fakeModule2;
expect(function() { Plotly.Plots.register(fm2, 'newtype', ['yellow', 'blue']); })
.toThrow(new Error('type newtype already registered'));
expect(Plotly.Plots.allCategories.yellow).toBeUndefined();
it('should warn on attempts to reregister a type', function() {
Plots.register(this.fakeModule2, 'newtype', ['yellow', 'blue']);
expect(Plots.allCategories.yellow).toBeUndefined();
});

it('should find the module for a type', function() {
expect(Plotly.Plots.getModule('newtype')).toBe(this.fakeModule);
expect(Plotly.Plots.getModule({type: 'newtype'})).toBe(this.fakeModule);
expect(Plots.getModule('newtype')).toBe(this.fakeModule);
expect(Plots.getModule({type: 'newtype'})).toBe(this.fakeModule);
});

it('should return false for types it doesn\'t know', function() {
expect(Plotly.Plots.getModule('notatype')).toBe(false);
expect(Plotly.Plots.getModule({type: 'notatype'})).toBe(false);
expect(Plotly.Plots.getModule({type: 'newtype', r: 'this is polar'})).toBe(false);
expect(Plots.getModule('notatype')).toBe(false);
expect(Plots.getModule({type: 'notatype'})).toBe(false);
expect(Plots.getModule({type: 'newtype', r: 'this is polar'})).toBe(false);
});

it('should find the categories for this type', function() {
expect(Plotly.Plots.traceIs('newtype', 'red')).toBe(true);
expect(Plotly.Plots.traceIs({type: 'newtype'}, 'red')).toBe(true);
expect(Plots.traceIs('newtype', 'red')).toBe(true);
expect(Plots.traceIs({type: 'newtype'}, 'red')).toBe(true);
});

it('should not find other real categories', function() {
expect(Plotly.Plots.traceIs('newtype', 'cartesian')).toBe(false);
expect(Plotly.Plots.traceIs({type: 'newtype'}, 'cartesian')).toBe(false);
expect(Plots.traceIs('newtype', 'cartesian')).toBe(false);
expect(Plots.traceIs({type: 'newtype'}, 'cartesian')).toBe(false);
expect(console.warn).not.toHaveBeenCalled();
});
});

describe('Plotly.Plots.registerSubplot', function() {
describe('Plots.registerSubplot', function() {
var fake = {
name: 'fake',
attr: 'abc',
idRoot: 'cba',
attributes: { stuff: { 'more stuff': 102102 } }
};

Plotly.Plots.registerSubplot(fake);
Plots.registerSubplot(fake);

var subplotsRegistry = Plotly.Plots.subplotsRegistry;
var subplotsRegistry = Plots.subplotsRegistry;

it('should register attr, idRoot and attributes', function() {
expect(subplotsRegistry.fake.attr).toEqual('abc');
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('Test Plotly.Plots', function() {

});

describe('Plotly.Plots.purge', function() {
describe('Plots.purge', function() {
var gd;

beforeEach(function(done) {
Expand All @@ -324,7 +324,7 @@ describe('Test Plotly.Plots', function() {
'_hmpixcount', '_hmlumcount'
];

Plotly.Plots.purge(gd);
Plots.purge(gd);
expect(Object.keys(gd)).toEqual(expectedKeys);
expect(gd.data).toBeUndefined();
expect(gd.layout).toBeUndefined();
Expand Down
4 changes: 1 addition & 3 deletions test/jasmine/tests/scattergeo_test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var Plotly = require('@src/plotly');
var ScatterGeo = require('@src/traces/scattergeo');

describe('Test scattergeo', function() {
'use strict';

var ScatterGeo = Plotly.ScatterGeo;

describe('supplyDefaults', function() {
var traceIn,
traceOut;
Expand Down