Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Li <[email protected]>
  • Loading branch information
lixun910 committed Dec 8, 2023
1 parent 7a529dd commit b34ac84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/reducers/src/combined-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const addDataToMapUpdater = (
// check if progresive loading dataset by bataches
const isProgressiveLoading =
Array.isArray(datasets) &&
datasets[0].info.format === 'arrow' &&
datasets[0].info.id &&
datasets[0].info.id in state.visState.datasets;

Expand Down
23 changes: 18 additions & 5 deletions test/browser/file-handler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/* eslint-disable max-statements */
import test from 'tape';
import {generateHashIdFromString} from '@kepler.gl/utils';
import {processFileData, readFileInBatches, csvWithNull} from '@kepler.gl/processors';
import {dataWithNulls, testFields, parsedDataWithNulls} from 'test/fixtures/test-csv-data';
import geojsonString, {
Expand Down Expand Up @@ -136,7 +137,7 @@ test('#file-handler -> readFileInBatches.csv -> processFileData', async t => {

// go on to run processFileData
const processed = await processFileData({content: batch2.value, fileCache: []});
const expectedInfo = {label: 'text-data.csv', format: 'row'};
const expectedInfo = {id: generateHashIdFromString('text-data.csv'), label: 'text-data.csv', format: 'row'};

t.equal(processed.length, 1, 'processFileData should return 1 result');
t.ok(processed[0].info, 'processFileData should have info');
Expand Down Expand Up @@ -266,7 +267,11 @@ test('#file-handler -> readFileInBatches.GeoJSON FeatureCollection -> processFil

// process geojson data received
const processed = await processFileData({content: batch4.value, fileCache: []});
const expectedInfo = {label: 'text-data-1.geojson', format: 'geojson'};
const expectedInfo = {
id: generateHashIdFromString('text-data-1.geojson'),
label: 'text-data-1.geojson',
format: 'geojson'
};

t.equal(processed.length, 1, 'processFileData should return 1 result');
t.ok(processed[0].info, 'processFileData should have info');
Expand Down Expand Up @@ -367,7 +372,11 @@ test('#file-handler -> readFileInBatches.GeoJSON Single Feature -> processFileDa

// process geojson data received
const processed = await processFileData({content: batch2.value, fileCache: []});
const expectedInfo = {label: 'text-data-1.geojson', format: 'geojson'};
const expectedInfo = {
id: generateHashIdFromString('text-data-1.geojson'),
label: 'text-data-1.geojson',
format: 'geojson'
};

t.equal(processed.length, 1, 'processFileData should return 1 result');
t.ok(processed[0].info, 'processFileData should have info');
Expand Down Expand Up @@ -498,7 +507,7 @@ test('#file-handler -> readFileInBatches.row -> processFileData', async t => {
fields: parsedFields,
rows: parsedRows
},
info: {label: fileName, format: 'row'}
info: {id: generateHashIdFromString(fileName), label: fileName, format: 'row'}
}
];
t.equal(processed.length, 1, 'processFileData should return 1 result');
Expand Down Expand Up @@ -624,7 +633,11 @@ test('#file-handler -> readFileInBatches.keplerMap -> processFileData', async t

// process file
const processed = await processFileData({content: batch4.value, fileCache: []});
const expectedInfo = {label: fileName, format: 'keplergl'};
const expectedInfo = {
id: generateHashIdFromString(fileName),
label: fileName,
format: 'keplergl'
};

const expectedFileCache = [
{
Expand Down

0 comments on commit b34ac84

Please sign in to comment.