mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Remove deep clone, just use type & geometry for features on maps end * Remove file parser clone test * Review feedback * Set properties default to empty object since there's downstream modification * Review feedback
This commit is contained in:
parent
7e0a615b38
commit
3fe7ed3e52
3 changed files with 12 additions and 25 deletions
|
@ -35,7 +35,7 @@ export function jsonPreview(json, previewFunction) {
|
|||
// Call preview (if any)
|
||||
if (json && previewFunction) {
|
||||
const defaultName = _.get(json, 'name', 'Import File');
|
||||
previewFunction(_.cloneDeep(json), defaultName);
|
||||
previewFunction(json, defaultName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { parseFile, jsonPreview } from './file_parser';
|
||||
import { parseFile } from './file_parser';
|
||||
|
||||
describe('parse file', () => {
|
||||
const cleanAndValidate = jest.fn(a => a);
|
||||
|
@ -61,26 +61,4 @@ describe('parse file', () => {
|
|||
// Confirm preview function called
|
||||
expect(previewFunction.mock.calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should use object clone for preview function', () => {
|
||||
const justFinalJson = {
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
'type': 'Polygon',
|
||||
'coordinates': [[
|
||||
[-104.05, 78.99],
|
||||
[-87.22, 78.98],
|
||||
[-86.58, 75.94],
|
||||
[-104.03, 75.94],
|
||||
[-104.05, 78.99]
|
||||
]]
|
||||
},
|
||||
};
|
||||
|
||||
jsonPreview(justFinalJson, previewFunction);
|
||||
// Confirm equal object passed
|
||||
expect(previewFunction.mock.calls[0][0]).toEqual(justFinalJson);
|
||||
// Confirm not the same object
|
||||
expect(previewFunction.mock.calls[0][0]).not.toBe(justFinalJson);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -107,8 +107,17 @@ export class GeojsonFileSource extends AbstractVectorSource {
|
|||
}
|
||||
|
||||
async getGeoJsonWithMeta() {
|
||||
const copiedPropsFeatures = this._descriptor.featureCollection.features
|
||||
.map(feature => ({
|
||||
type: 'Feature',
|
||||
geometry: feature.geometry,
|
||||
properties: feature.properties ? { ...feature.properties } : {}
|
||||
}));
|
||||
return {
|
||||
data: this._descriptor.featureCollection,
|
||||
data: {
|
||||
type: 'FeatureCollection',
|
||||
features: copiedPropsFeatures
|
||||
},
|
||||
meta: {}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue