Initial commit
This commit is contained in:
247
test/spec/api/createVis/create-vis.spec.js
Normal file
247
test/spec/api/createVis/create-vis.spec.js
Normal file
@@ -0,0 +1,247 @@
|
||||
var $ = require('jquery');
|
||||
var createVis = require('../../../../src/api/create-vis');
|
||||
var scenarios = require('./scenarios');
|
||||
var Loader = require('../../../../src/core/loader');
|
||||
|
||||
describe('create-vis:', function () {
|
||||
beforeEach(function () {
|
||||
this.container = $('<div id="map">').css('height', '200px');
|
||||
this.containerId = this.container[0].id;
|
||||
$('body').append(this.container);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
this.container.remove();
|
||||
});
|
||||
|
||||
it('should throw errors when required parameters are missing', function () {
|
||||
expect(function () {
|
||||
createVis();
|
||||
}).toThrowError('a valid DOM element or selector must be provided');
|
||||
|
||||
expect(function () {
|
||||
createVis('something');
|
||||
}).toThrowError('a valid DOM element or selector must be provided');
|
||||
|
||||
expect(function () {
|
||||
createVis(this.containerId);
|
||||
}.bind(this)).toThrowError('a vizjson URL or object must be provided');
|
||||
|
||||
expect(function () {
|
||||
createVis(this.container[0], 'vizjson');
|
||||
}.bind(this)).not.toThrowError();
|
||||
|
||||
expect(function () {
|
||||
createVis(this.containerId, 'vizjson');
|
||||
}.bind(this)).not.toThrowError();
|
||||
});
|
||||
|
||||
it('should use the given vis.json (instead downloading) when the visjson parameter is provided', function () {
|
||||
spyOn(Loader, 'get');
|
||||
var visJson = scenarios.load('basic');
|
||||
createVis(this.containerId, visJson);
|
||||
expect(Loader.get).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should download the vizjson file from a URL when the visjson parameter is provided and is a string', function () {
|
||||
spyOn(Loader, 'get');
|
||||
createVis(this.containerId, 'www.example.com/fake_vis.json');
|
||||
expect(Loader.get).toHaveBeenCalledWith('www.example.com/fake_vis.json', jasmine.any(Function));
|
||||
});
|
||||
|
||||
describe('Default (no Options)', function () {
|
||||
it('should get the map center from the visJson', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('center')).toEqual(visJson.center);
|
||||
});
|
||||
|
||||
it('should get the title from the visJson', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.get('title')).toEqual(visJson.title);
|
||||
});
|
||||
|
||||
it('should get the description from the visJson', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.get('description')).toEqual(visJson.description);
|
||||
});
|
||||
|
||||
it('should initialize the right protocol (https:false)', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.get('https')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should not have interactive features by default', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.get('interactiveFeatures')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should display the "loader" overlay by default [loaderControl, tiles_loader]', function () {
|
||||
// loaderControl and tiles_loader appear to do the same.
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'loader' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should display the "logo" by default', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'logo' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not display empty infowindow fields by default', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.get('showEmptyInfowindowFields')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should have legends', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.settings.get('showLegends')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should show layer selector', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.settings.get('showLayerSelector')).toEqual(true);
|
||||
expect(visModel.settings.get('layerSelectorEnabled')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should allow scrollwheel by default', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('scrollwheel')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Options', function () {
|
||||
describe('skipMapInstantiation', function () {
|
||||
it('should instantiate map when skipMapInstantiation option is falsy', function (done) {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
setTimeout(function () {
|
||||
expect(visModel._instantiateMapWasCalled).toEqual(true);
|
||||
done();
|
||||
}, 25);
|
||||
});
|
||||
|
||||
it('should NOT instantiate map when skipMapInstantiation option is truthy', function (done) {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson, { skipMapInstantiation: true });
|
||||
setTimeout(function () {
|
||||
expect(visModel._instantiateMapWasCalled).toEqual(false);
|
||||
done();
|
||||
}, 25);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('VisModel.map', function () {
|
||||
it('should have the right title', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('title')).toEqual(visJson.title);
|
||||
});
|
||||
|
||||
it('should have the right description', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('description')).toEqual(visJson.description);
|
||||
});
|
||||
|
||||
it('should have the right bounds', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('view_bounds_sw')).toEqual(visJson.bounds[0]);
|
||||
expect(visModel.map.get('view_bounds_ne')).toEqual(visJson.bounds[1]);
|
||||
});
|
||||
|
||||
it('should have the right zoom', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('zoom')).toEqual(visJson.zoom);
|
||||
});
|
||||
|
||||
it('should have the right scrollwheel', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('scrollwheel')).toEqual(visJson.options.scrollwheel);
|
||||
});
|
||||
|
||||
it('should have the right drag', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('drag')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should have the right provider', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('provider')).toEqual('leaflet');
|
||||
});
|
||||
|
||||
it('should have the right feature interactivity', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('isFeatureInteractivityEnabled')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should have the right render mode', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.map.get('renderMode')).toEqual(visJson.vector ? 'vector' : 'raster');
|
||||
});
|
||||
});
|
||||
|
||||
describe('VisModel.overlays', function () {
|
||||
it('should have a share overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
// TODO: Review if this overlay is still supported!
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'share' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have a search overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'search' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have a zoom overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'zoom' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have a loader overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'loader' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have a logo overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'logo' })).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have a attribution overlay', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel.overlaysCollection.findWhere({ type: 'attribution' })).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('VisModel._dataviewsCollection', function () {
|
||||
it('should not have dataviews', function () {
|
||||
var visJson = scenarios.load('basic');
|
||||
var visModel = createVis(this.containerId, visJson);
|
||||
expect(visModel._dataviewsCollection.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
314
test/spec/api/createVis/scenarios/basic_vis.json.js
Normal file
314
test/spec/api/createVis/scenarios/basic_vis.json.js
Normal file
@@ -0,0 +1,314 @@
|
||||
module.exports = {
|
||||
'bounds': [
|
||||
[
|
||||
38.994,
|
||||
-8.74622
|
||||
],
|
||||
[
|
||||
42.3508,
|
||||
-1.86658
|
||||
]
|
||||
],
|
||||
'center': [
|
||||
40.67241595,
|
||||
-5.306396485
|
||||
],
|
||||
'datasource': {
|
||||
'user_name': 'iago-carto',
|
||||
'maps_api_template': 'https://{user}.carto.com:443',
|
||||
'stat_tag': 'd71f6316-b2df-4a33-8109-fa80e8fc793d',
|
||||
'template_name': 'tpl_d71f6316_b2df_4a33_8109_fa80e8fc793d'
|
||||
},
|
||||
'description': null,
|
||||
'options': {
|
||||
'legends': true,
|
||||
'scrollwheel': true,
|
||||
'layer_selector': true,
|
||||
'dashboard_menu': true
|
||||
},
|
||||
'id': 'd71f6316-b2df-4a33-8109-fa80e8fc793d',
|
||||
'layers': [
|
||||
{
|
||||
'id': '5bdcb792-78ce-4875-8ab1-869561916426',
|
||||
'type': 'tiled',
|
||||
'options': {
|
||||
'default': 'true',
|
||||
'url': 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_nolabels/{z}/{x}/{y}.png',
|
||||
'subdomains': 'abcd',
|
||||
'minZoom': '0',
|
||||
'maxZoom': '18',
|
||||
'name': 'Positron',
|
||||
'className': 'positron_rainbow_labels',
|
||||
'attribution': "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors",
|
||||
'labels': {
|
||||
'url': 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_only_labels/{z}/{x}/{y}.png'
|
||||
},
|
||||
'urlTemplate': 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_nolabels/{z}/{x}/{y}.png'
|
||||
}
|
||||
},
|
||||
{
|
||||
'id': '1b65ba49-e202-4a0a-bb4d-5d8a416788cd',
|
||||
'type': 'CartoDB',
|
||||
'visible': true,
|
||||
'options': {
|
||||
'layer_name': 'lugares',
|
||||
'attribution': '',
|
||||
'cartocss': '#layer {\n marker-width: ramp([population], range(6, 33), quantiles(5));\n marker-fill: #279aff;\n marker-fill-opacity: 0.9;\n marker-allow-overlap: true;\n marker-line-width: 1;\n marker-line-color: #FFF;\n marker-line-opacity: 1;\n}',
|
||||
'source': 'a0'
|
||||
},
|
||||
'infowindow': {
|
||||
'template_name': 'infowindow_color',
|
||||
'fields': [
|
||||
{
|
||||
'name': 'population',
|
||||
'title': true,
|
||||
'position': null
|
||||
},
|
||||
{
|
||||
'name': 'description',
|
||||
'title': true,
|
||||
'position': null
|
||||
}
|
||||
],
|
||||
'maxHeight': 180,
|
||||
'template': "<div class='CDB-infowindow CDB-infowindow--light js-infowindow'>\n <div class='CDB-infowindow-close js-close'></div>\n <div class='CDB-infowindow-container'>\n <div class='CDB-infowindow-header CDB-infowindow-headerBg CDB-infowindow-headerBg--light js-header' style='background: #35AAE5;'>\n {{#loading}}\u2026{{/loading}}\n <ul class='CDB-infowindow-list'>\n {{#content.fields}}\n {{^index}}\n <li class='CDB-infowindow-listItem'>\n {{#title}}<h5 class='CDB-infowindow-subtitle'>{{title}}</h5>{{/title}}\n {{#value}}<h4 class='CDB-infowindow-title {{#type}}{{ type }}{{/type}}'>{{{ value }}}</h4>{{/value}}\n </li>\n {{^value}}{{/value}}\n {{/index}}\n {{/content.fields}}\n </ul>\n </div>\n <div class='CDB-infowindow-inner js-inner'>\n {{#loading}}\n <div class='CDB-Loader js-loader is-visible'></div>\n {{/loading}}\n <ul class='CDB-infowindow-list js-content'>\n {{#content.fields}}\n {{#index}}\n <li class='CDB-infowindow-listItem'>\n {{#title}}\n <h5 class='CDB-infowindow-subtitle'>{{title}}</h5>\n {{/title}}\n {{#value}}\n <h4 class='CDB-infowindow-title'>{{{ value }}}</h4>\n {{/value}}\n {{^value}}\n <h4 class='CDB-infowindow-title'>NULL</h4>\n {{/value}}\n </li>\n {{/index}}\n {{/content.fields}}\n </ul>\n </div>\n <div class='CDB-hook'>\n <div class='CDB-hook-inner'></div>\n </div>\n </div>\n</div>\n",
|
||||
'alternative_names': {
|
||||
'name': '',
|
||||
'description': ''
|
||||
},
|
||||
'width': 226,
|
||||
'headerColor': {
|
||||
'color': {
|
||||
'fixed': '#35AAE5',
|
||||
'opacity': 1
|
||||
}
|
||||
},
|
||||
'template_type': 'mustache'
|
||||
},
|
||||
'tooltip': {
|
||||
'fields': [
|
||||
{
|
||||
'name': 'name',
|
||||
'title': true,
|
||||
'position': null
|
||||
},
|
||||
{
|
||||
'name': 'description',
|
||||
'title': true,
|
||||
'position': null
|
||||
}
|
||||
],
|
||||
'template_name': 'tooltip_dark',
|
||||
'template': "<div class='CDB-Tooltip CDB-Tooltip--isDark'>\n <ul class='CDB-Tooltip-list'>\n {{#fields}}\n <li class='CDB-Tooltip-listItem'>\n {{#title}}\n <h3 class='CDB-Tooltip-listTitle'>{{{ title }}}</h3>\n {{/title}}\n <h4 class='CDB-Tooltip-listText'>{{{ value }}}</h4>\n </li>\n {{/fields}}\n </ul>\n</div>\n",
|
||||
'template_type': 'mustache'
|
||||
},
|
||||
'legends': [
|
||||
{
|
||||
'conf': {
|
||||
'columns': [
|
||||
'title'
|
||||
]
|
||||
},
|
||||
'created_at': '2017-08-31T14:58:44+00:00',
|
||||
'definition': {
|
||||
'categories': [
|
||||
{
|
||||
'title': 'Iago',
|
||||
'color': '#279aff'
|
||||
},
|
||||
{
|
||||
'title': 'Pablo',
|
||||
'color': '#e7c5ce'
|
||||
},
|
||||
{
|
||||
'title': 'Untitled',
|
||||
'color': '#528995'
|
||||
}
|
||||
]
|
||||
},
|
||||
'id': 'cc81d782-0037-4cba-9575-abe817147bfa',
|
||||
'layer_id': '1b65ba49-e202-4a0a-bb4d-5d8a416788cd',
|
||||
'post_html': '',
|
||||
'pre_html': '',
|
||||
'title': 'Wadus',
|
||||
'type': 'custom',
|
||||
'updated_at': '2017-08-31T14:59:29+00:00'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'a58f47f9-7fb2-4539-a7e6-dcedd7adc9e4',
|
||||
'type': 'tiled',
|
||||
'options': {
|
||||
'default': 'true',
|
||||
'url': 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_only_labels/{z}/{x}/{y}.png',
|
||||
'subdomains': 'abcd',
|
||||
'minZoom': '0',
|
||||
'maxZoom': '18',
|
||||
'attribution': "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors",
|
||||
'urlTemplate': 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_only_labels/{z}/{x}/{y}.png',
|
||||
'type': 'Tiled',
|
||||
'name': 'Positron Labels'
|
||||
}
|
||||
}
|
||||
],
|
||||
'likes': 0,
|
||||
'map_provider': 'leaflet',
|
||||
'overlays': [
|
||||
{
|
||||
'type': 'share',
|
||||
'order': 2,
|
||||
'options': {
|
||||
'display': true,
|
||||
'x': 20,
|
||||
'y': 20
|
||||
},
|
||||
'template': ''
|
||||
},
|
||||
{
|
||||
'type': 'search',
|
||||
'order': 3,
|
||||
'options': null,
|
||||
'template': null
|
||||
},
|
||||
{
|
||||
'type': 'zoom',
|
||||
'order': 6,
|
||||
'options': null,
|
||||
'template': null
|
||||
},
|
||||
{
|
||||
'type': 'loader',
|
||||
'order': 8,
|
||||
'options': {
|
||||
'display': true,
|
||||
'x': 20,
|
||||
'y': 150
|
||||
},
|
||||
'template': "<div class='loader' original-title=''></div>"
|
||||
},
|
||||
{
|
||||
'type': 'logo',
|
||||
'order': 10,
|
||||
'options': null,
|
||||
'template': null
|
||||
}
|
||||
],
|
||||
'title': 'Cities',
|
||||
'updated_at': '2017-08-31T15:36:12+00:00',
|
||||
'user': {
|
||||
'fullname': 'Iago Lastra',
|
||||
'avatar_url': 'https://s3.amazonaws.com/com.cartodb.users-assets.production/production/iago-carto/assets/20170720105148Avatar250.png',
|
||||
'profile_url': 'https://team.carto.com/u/iago-carto'
|
||||
},
|
||||
'version': '3.0.0',
|
||||
'widgets': [
|
||||
{
|
||||
'id': '30a96a5d-349d-49c4-875a-c6eba7485635',
|
||||
'type': 'category',
|
||||
'title': 'name',
|
||||
'order': 0,
|
||||
'layer_id': '1b65ba49-e202-4a0a-bb4d-5d8a416788cd',
|
||||
'options': {
|
||||
'column': 'name',
|
||||
'aggregation_column': 'name',
|
||||
'aggregation': 'count',
|
||||
'column_type': 'string',
|
||||
'sync_on_bbox_change': true
|
||||
},
|
||||
'style': {
|
||||
'widget_style': {
|
||||
'definition': {
|
||||
'color': {
|
||||
'fixed': '#9DE0AD',
|
||||
'opacity': 1
|
||||
}
|
||||
},
|
||||
'widget_color_changed': false
|
||||
},
|
||||
'auto_style': {
|
||||
'custom': false,
|
||||
'allowed': true
|
||||
}
|
||||
},
|
||||
'source': {
|
||||
'id': 'a0'
|
||||
}
|
||||
},
|
||||
{
|
||||
'id': '3d26c92f-0244-4479-9fc0-fb0715283ecd',
|
||||
'type': 'histogram',
|
||||
'title': 'population',
|
||||
'order': 2,
|
||||
'layer_id': '1b65ba49-e202-4a0a-bb4d-5d8a416788cd',
|
||||
'options': {
|
||||
'column': 'population',
|
||||
'bins': 10,
|
||||
'column_type': 'number',
|
||||
'sync_on_bbox_change': true
|
||||
},
|
||||
'style': {
|
||||
'widget_style': {
|
||||
'definition': {
|
||||
'color': {
|
||||
'fixed': '#9DE0AD',
|
||||
'opacity': 1
|
||||
}
|
||||
},
|
||||
'widget_color_changed': false
|
||||
},
|
||||
'auto_style': {
|
||||
'custom': false,
|
||||
'allowed': true
|
||||
}
|
||||
},
|
||||
'source': {
|
||||
'id': 'a0'
|
||||
}
|
||||
},
|
||||
{
|
||||
'id': 'd0d44271-43ef-468f-b2e5-64f4a266daa4',
|
||||
'type': 'category',
|
||||
'title': 'name',
|
||||
'order': 3,
|
||||
'layer_id': '1b65ba49-e202-4a0a-bb4d-5d8a416788cd',
|
||||
'options': {
|
||||
'column': 'name',
|
||||
'aggregation_column': 'name',
|
||||
'aggregation': 'count',
|
||||
'column_type': 'string',
|
||||
'sync_on_bbox_change': true
|
||||
},
|
||||
'style': {
|
||||
'widget_style': {
|
||||
'definition': {
|
||||
'color': {
|
||||
'fixed': '#9DE0AD',
|
||||
'opacity': 1
|
||||
}
|
||||
},
|
||||
'widget_color_changed': false
|
||||
},
|
||||
'auto_style': {
|
||||
'custom': false,
|
||||
'allowed': true
|
||||
}
|
||||
},
|
||||
'source': {
|
||||
'id': 'a0'
|
||||
}
|
||||
}
|
||||
],
|
||||
'zoom': 6,
|
||||
'analyses': [
|
||||
{
|
||||
'id': 'a0',
|
||||
'type': 'source',
|
||||
'options': {
|
||||
'table_name': "'iago-carto'.lugares",
|
||||
'simple_geom': 'point'
|
||||
}
|
||||
}
|
||||
],
|
||||
'vector': false
|
||||
};
|
||||
19
test/spec/api/createVis/scenarios/index.js
Normal file
19
test/spec/api/createVis/scenarios/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Load a vis.json from the scenarios folder
|
||||
* It returns a copy from the object to easy reusing.
|
||||
*/
|
||||
function load (index) {
|
||||
// We use a switch because our current build system doesn't support variables in the require.
|
||||
switch (index) {
|
||||
case 'basic':
|
||||
return clone(require('./basic_vis.json.js'));
|
||||
}
|
||||
}
|
||||
|
||||
function clone (object) {
|
||||
return JSON.parse(JSON.stringify(object));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
load: load
|
||||
};
|
||||
Reference in New Issue
Block a user