Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
};
}
Expand Down