tests convertproperty of engine

This commit is contained in:
Tykayn 2023-08-18 12:08:25 +02:00 committed by tykayn
parent c3d6004b18
commit c7629c6c04
4 changed files with 14 additions and 14 deletions

View File

@ -10,9 +10,7 @@ const MappingTest: MappingConfigType = {
config_author: 'tykayn <contact@cipherbliss.com>', config_author: 'tykayn <contact@cipherbliss.com>',
default_properties_of_point: {}, default_properties_of_point: {},
tags: { tags: {
consolidated_is_lon_lat_correct: { nom_amenageur : 'name'
convert_to_boolean_value: true,
},
}, },
add_not_mapped_tags_too: false, add_not_mapped_tags_too: false,
source: {}, source: {},

View File

@ -89,7 +89,7 @@ export default class {
* retuns the converted element from mapping config if present, null otherwise * retuns the converted element from mapping config if present, null otherwise
*/ */
mapElementFromConf(featurePoint: any): any { mapElementFromConf(featurePoint: any): any {
// debugLog('mapElementFromConf: mapElementFromConf', featurePoint) debugLog('mapElementFromConf: mapElementFromConf', featurePoint)
if (!this.mapping_config) { if (!this.mapping_config) {
throw new Error('no config was loaded in the mapping engine. use setConfig(my_mapping_config) on this instance of mapping engine before using this. Your config should be typed to MappingConfigType Type.') throw new Error('no config was loaded in the mapping engine. use setConfig(my_mapping_config) on this instance of mapping engine before using this. Your config should be typed to MappingConfigType Type.')
} }
@ -340,6 +340,7 @@ export default class {
} }
} }
return newProperties;
} }
} }

View File

@ -11,7 +11,7 @@
] ]
}, },
"properties": { "properties": {
"consolidated_is_lon_lat_correct": "yes" "name": "Bob"
} }
} }
] ]

View File

@ -1,5 +1,5 @@
import mapping_engine from '../mappings/engine.ts' import mapping_engine from '../mappings/engine.ts'
import { mappingPhone, mappingRemoveAll , mappingBoolean} from '../data_other/testing/mappings_to_test' import { mappingPhone, mappingRemoveAll, mappingBoolean, mappingName } from '../data_other/testing/mappings_to_test'
const testingGeoJson = require('../data_other/testing/testing.json') const testingGeoJson = require('../data_other/testing/testing.json')
@ -30,14 +30,15 @@ describe('mapping properties with rich mapping engine', () => {
let Mapping_engine = new mapping_engine(mappingRemoveAll) let Mapping_engine = new mapping_engine(mappingRemoveAll)
expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingRemoveAll') expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingRemoveAll')
}) })
// test('maps nom_amenageur to name, and keep the same value', () => { test('maps nom_amenageur to name, and keep the same value', () => {
// let Mapping_engine = new mapping_engine(mappingName) let Mapping_engine = new mapping_engine(mappingName)
// let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test) let newProperties = Mapping_engine.convertProperty('nom_amenageur',Object.keys(mappingName.tags),feature_to_test,mappingName.default_properties_of_point )
// expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingName') expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingName')
// expect(mapped_point.properties).toBe({
// name : "Bob" expect(newProperties).toStrictEqual({
// }) name : "Bob"
// }) })
})
// test('ignore one value', () => { }) // test('ignore one value', () => { })
// test('conditional value', () => { }) // test('conditional value', () => { })
// test('conditional transform', () => { }) // test('conditional transform', () => { })