mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
add tilemap map tests
tests around creating new maps
This commit is contained in:
parent
40fdc44bd6
commit
60a4ea3a40
2 changed files with 89 additions and 2 deletions
|
@ -7,6 +7,8 @@ define(function (require) {
|
|||
|
||||
var defaultMapZoom = 2;
|
||||
var defaultMapCenter = [15, 5];
|
||||
var defaultMarkerType = 'Scaled Circle Markers';
|
||||
|
||||
var mapTiles = {
|
||||
url: 'https://otile{s}-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
|
||||
options: {
|
||||
|
@ -16,6 +18,7 @@ define(function (require) {
|
|||
subdomains: '1234'
|
||||
}
|
||||
};
|
||||
|
||||
var markerTypes = {
|
||||
'Scaled Circle Markers': Private(require('components/vislib/visualizations/marker_types/scaled_circles')),
|
||||
'Shaded Circle Markers': Private(require('components/vislib/visualizations/marker_types/shaded_circles')),
|
||||
|
@ -23,13 +26,12 @@ define(function (require) {
|
|||
'Heatmap': Private(require('components/vislib/visualizations/marker_types/heatmap')),
|
||||
};
|
||||
|
||||
var defaultMarkerType = 'Scaled Circle Markers';
|
||||
|
||||
/**
|
||||
* Tile Map Maps
|
||||
*
|
||||
* @class Map
|
||||
* @constructor
|
||||
* @param container {HTML Element} Element to render map into
|
||||
* @param chartData {Object} Elasticsearch query results for this map
|
||||
* @param params {Object} Parameters used to build a map
|
||||
*/
|
||||
|
|
85
test/unit/specs/vislib/visualizations/tile_maps/map.js
Normal file
85
test/unit/specs/vislib/visualizations/tile_maps/map.js
Normal file
|
@ -0,0 +1,85 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
var L = require('leaflet');
|
||||
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var geoJsonData = require('vislib_fixtures/mock_data/geohash/_geo_json');
|
||||
|
||||
angular.module('MapFactory', ['kibana']);
|
||||
|
||||
describe('TileMap Map', function () {
|
||||
var $mockMapEl = $('<div>');
|
||||
var Map;
|
||||
var map;
|
||||
var leafletMock = {};
|
||||
|
||||
beforeEach(function () {
|
||||
module('MapFactory');
|
||||
inject(function (Private) {
|
||||
Map = Private(require('components/vislib/visualizations/_map'));
|
||||
|
||||
leafletMock.map = {
|
||||
on: sinon.stub()
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('instantiation', function () {
|
||||
var createStub;
|
||||
|
||||
beforeEach(function () {
|
||||
createStub = sinon.stub(Map.prototype, '_createMap', _.noop);
|
||||
map = new Map($mockMapEl, geoJsonData, {});
|
||||
});
|
||||
|
||||
it('should create the map', function () {
|
||||
expect(createStub.callCount).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createMap', function () {
|
||||
var stubs;
|
||||
var mapStubs;
|
||||
|
||||
beforeEach(function () {
|
||||
stubs = {
|
||||
layer: sinon.stub(L, 'tileLayer'),
|
||||
map: sinon.stub(L, 'map', _.constant(leafletMock.map)),
|
||||
};
|
||||
|
||||
mapStubs = {
|
||||
destroy: sinon.stub(Map.prototype, 'destroy'),
|
||||
attachEvents: sinon.stub(Map.prototype, '_attachEvents'),
|
||||
addMarkers: sinon.stub(Map.prototype, '_addMarkers'),
|
||||
};
|
||||
|
||||
map = new Map($mockMapEl, geoJsonData, {});
|
||||
});
|
||||
|
||||
it('should create the create leaflet objects', function () {
|
||||
expect(stubs.layer.callCount).to.equal(1);
|
||||
expect(stubs.map.callCount).to.equal(1);
|
||||
|
||||
var callArgs = stubs.map.firstCall.args;
|
||||
var mapOptions = callArgs[1];
|
||||
expect(callArgs[0]).to.be($mockMapEl.get(0));
|
||||
expect(mapOptions).to.have.property('zoom');
|
||||
expect(mapOptions).to.have.property('center');
|
||||
});
|
||||
|
||||
it('should attach events and add markers', function () {
|
||||
expect(mapStubs.attachEvents.callCount).to.equal(1);
|
||||
expect(mapStubs.addMarkers.callCount).to.equal(1);
|
||||
});
|
||||
|
||||
it('should call destroy only if a map exists', function () {
|
||||
expect(mapStubs.destroy.callCount).to.equal(0);
|
||||
map._createMap({});
|
||||
expect(mapStubs.destroy.callCount).to.equal(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue