Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Chore] add test for vis state schema column save undefined typeerror (#2219)
Igor Df80853b05551
diff --git a/src/layers/src/base-layer.ts b/src/layers/src/base-layer.tsindex 6e79fbea4..8190ebbfc 100644--- a/src/layers/src/base-layer.ts+++ b/src/layers/src/base-layer.ts@@ -867,8 +867,8 @@ class Layer {const {columns} = this.config;return (columns &&- Object.values(columns).every(v => {- return Boolean(v.optional || (v.value && v.fieldIdx > -1));+ Object.values(columns).every(column => {+ return Boolean(column && (column.optional || (column.value && column.fieldIdx > -1)));}));}diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.jsindex 5da9d1f29..fa553c23e 100644--- a/test/node/schemas/vis-state-schema-test.js+++ b/test/node/schemas/vis-state-schema-test.js@@ -21,9 +21,10 @@import test from 'tape';import cloneDeep from 'lodash.clonedeep';import {cmpFilters, cmpSavedLayers} from 'test/helpers/comparison-utils';-import SchemaManager from '@kepler.gl/schemas';+import SchemaManager, {CURRENT_VERSION, visStateSchema} from '@kepler.gl/schemas';import {+ StateWFiles,StateWFilesFiltersLayerColor,StateWTooltipFormat,expectedSavedLayer0,@@ -322,3 +323,20 @@ test('#visStateSchema -> v1 -> save animation', t => {t.deepEqual(vsToSave.animationConfig, expectedAnimationConfig, 'should save animationConfig');t.end();});++test('visStateSchema -> saving with a null column value does not throw an error', t => {+ const testLayer = cloneDeep(StateWFiles).visState.layers[0];++ // set a column to null+ testLayer.config.columns.altitude = null;++ // test that it doesn't fail ColumnSchemaV1.save+ t.doesNotThrow(() => {+ visStateSchema[CURRENT_VERSION].save({+ layers: [testLayer],+ layerOrder: [testLayer.id]+ });+ }, 'saving with a null column value should not fail');++ t.end();+});