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>',
default_properties_of_point: {},
tags: {
consolidated_is_lon_lat_correct: {
convert_to_boolean_value: true,
},
nom_amenageur : 'name'
},
add_not_mapped_tags_too: false,
source: {},

View File

@ -89,7 +89,7 @@ export default class {
* retuns the converted element from mapping config if present, null otherwise
*/
mapElementFromConf(featurePoint: any): any {
// debugLog('mapElementFromConf: mapElementFromConf', featurePoint)
debugLog('mapElementFromConf: mapElementFromConf', featurePoint)
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.')
}
@ -340,6 +340,7 @@ export default class {
}
}
return newProperties;
}
}

View File

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

View File

@ -1,5 +1,5 @@
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')
@ -30,14 +30,15 @@ describe('mapping properties with rich mapping engine', () => {
let Mapping_engine = new mapping_engine(mappingRemoveAll)
expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingRemoveAll')
})
// test('maps nom_amenageur to name, and keep the same value', () => {
// let Mapping_engine = new mapping_engine(mappingName)
// let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
// expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingName')
// expect(mapped_point.properties).toBe({
// name : "Bob"
// })
// })
test('maps nom_amenageur to name, and keep the same value', () => {
let Mapping_engine = new mapping_engine(mappingName)
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(newProperties).toStrictEqual({
name : "Bob"
})
})
// test('ignore one value', () => { })
// test('conditional value', () => { })
// test('conditional transform', () => { })