2023-08-09 23:10:45 +02:00
|
|
|
import mapping_engine from '../mappings/engine.ts'
|
2023-08-18 12:22:07 +02:00
|
|
|
import {
|
|
|
|
mappingPhone,
|
|
|
|
mappingRemoveAll,
|
|
|
|
mappingBoolean,
|
|
|
|
mappingName,
|
|
|
|
mappingSame, mappingTruthy, mappingFalsy, mappingIgnoreFalsy, mappingIgnoreTruthy
|
|
|
|
} from '../data_other/testing/mappings_to_test'
|
2023-08-09 23:10:45 +02:00
|
|
|
|
|
|
|
const testingGeoJson = require('../data_other/testing/testing.json')
|
|
|
|
|
|
|
|
// import { describe, expect, test } from '@jest/globals'
|
|
|
|
|
|
|
|
describe('mapping properties with rich mapping engine', () => {
|
|
|
|
|
|
|
|
// test('do not add properties at all when there is nothing in tags of the mapping config', () => {
|
|
|
|
//
|
|
|
|
// })
|
2023-08-18 11:58:52 +02:00
|
|
|
let feature_to_test = testingGeoJson.features[0]
|
2023-08-09 23:10:45 +02:00
|
|
|
test('remove all properties when mapping says so', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingRemoveAll)
|
2023-08-18 11:25:02 +02:00
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
2023-08-09 23:10:45 +02:00
|
|
|
expect(mapped_point).toBeTruthy()
|
2023-08-18 11:25:02 +02:00
|
|
|
expect(Object.keys(mapped_point.properties)).toStrictEqual([])
|
2023-08-09 23:10:45 +02:00
|
|
|
|
|
|
|
})
|
2023-08-18 12:22:07 +02:00
|
|
|
test('maps simple key to key, and keep the same value', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingSame)
|
|
|
|
let newProperties = Mapping_engine.convertProperty('equal',
|
|
|
|
Object.keys(mappingSame.tags),
|
|
|
|
feature_to_test,
|
|
|
|
mappingSame.default_properties_of_point )
|
|
|
|
|
|
|
|
expect(newProperties).toStrictEqual({
|
|
|
|
equal : "same value"
|
|
|
|
})
|
|
|
|
})
|
2023-08-18 11:25:02 +02:00
|
|
|
test('retrieve config name in mapping engine', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingRemoveAll)
|
|
|
|
expect(Mapping_engine.getConfig().config_name).toBe('testing config mappingRemoveAll')
|
|
|
|
})
|
2023-08-18 12:08:25 +02:00
|
|
|
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"
|
|
|
|
})
|
|
|
|
})
|
2023-08-18 12:22:07 +02:00
|
|
|
test('ignore one value if it is truthy', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingIgnoreTruthy)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({})
|
|
|
|
})
|
|
|
|
test('ignore one value if it is falsy', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingIgnoreFalsy)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({})
|
|
|
|
})
|
2023-08-09 23:10:45 +02:00
|
|
|
// test('conditional value', () => { })
|
|
|
|
// test('conditional transform', () => { })
|
2023-08-18 12:22:07 +02:00
|
|
|
test('conditional truthy transform', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingTruthy)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({ consolidated_is_lon_lat_correct: 'succès' })
|
|
|
|
})
|
2023-08-18 11:58:52 +02:00
|
|
|
test('conditional falsy transform', () => {
|
2023-08-18 12:22:07 +02:00
|
|
|
let Mapping_engine = new mapping_engine(mappingFalsy)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({ consolidated_city: 'pas ouf succès' })
|
|
|
|
})
|
|
|
|
test('conditional boolean transform', () => {
|
2023-08-18 11:58:52 +02:00
|
|
|
let Mapping_engine = new mapping_engine(mappingBoolean)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({ consolidated_is_lon_lat_correct: 'yes' })
|
|
|
|
})
|
|
|
|
test('conditional phone transform', () => {
|
|
|
|
let Mapping_engine = new mapping_engine(mappingPhone)
|
|
|
|
let mapped_point = Mapping_engine.mapElementFromConf(feature_to_test)
|
|
|
|
expect(mapped_point.properties).toStrictEqual({ phone: '+33123456789' })
|
|
|
|
})
|
2023-08-09 23:10:45 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
xdescribe('filters points', () => {
|
|
|
|
test('filter no points', () => { })
|
|
|
|
test('filter only one point', () => { })
|
|
|
|
test('filter X number of points', () => { })
|
|
|
|
test('filter city points', () => { })
|
|
|
|
test('filter bounding box', () => { })
|
|
|
|
test('filter combo, city', () => { })
|
|
|
|
test('filter combo, city + bbox', () => { })
|
|
|
|
test('filter combo, city + bbox + offset', () => { })
|
|
|
|
})
|
|
|
|
|
|
|
|
/**
|
|
|
|
* thats a roadmap, yes
|
|
|
|
*/
|
|
|
|
xdescribe('infer domain of values from csv file', () => {
|
|
|
|
test('gets the list of unique values in column', () => { })
|
|
|
|
})
|
|
|
|
xdescribe('infer domain of values from geojson file', () => {
|
|
|
|
test('gets the list of unique values in column', () => { })
|
|
|
|
})
|
|
|
|
xdescribe('build mapping engine config from unique values', () => {
|
|
|
|
test('builds a valid mapping config', () => { })
|
|
|
|
})
|