|
|
@ -636,6 +636,104 @@ module.exports.tests.non_optimal_conditions = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('empire properties should be removed when there is a country_gid property', t => { |
|
|
|
|
|
|
|
const input = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_id: 'id 1', |
|
|
|
|
|
|
|
source: 'source 1', |
|
|
|
|
|
|
|
source_id: 'source_id 1', |
|
|
|
|
|
|
|
layer: 'layer 1', |
|
|
|
|
|
|
|
name: { |
|
|
|
|
|
|
|
default: 'name 1', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
center_point: { |
|
|
|
|
|
|
|
lat: 12.121212, |
|
|
|
|
|
|
|
lon: 21.212121 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_id: 'id 2', |
|
|
|
|
|
|
|
source: 'source 2', |
|
|
|
|
|
|
|
source_id: 'source_id 2', |
|
|
|
|
|
|
|
layer: 'layer 2', |
|
|
|
|
|
|
|
name: { |
|
|
|
|
|
|
|
default: 'name 2', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
center_point: { |
|
|
|
|
|
|
|
lat: 13.131313, |
|
|
|
|
|
|
|
lon: 31.313131 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const geojsonify = proxyquire('../../../helper/geojsonify', { |
|
|
|
|
|
|
|
'./geojsonify_place_details': (params, source, dst) => { |
|
|
|
|
|
|
|
if (source._id === 'id 1') { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
country_gid: 'country gid', |
|
|
|
|
|
|
|
empire_gid: 'empire gid', |
|
|
|
|
|
|
|
empire: 'empire', |
|
|
|
|
|
|
|
empire_a: 'empire abbr' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else if (source._id === 'id 2') { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
empire_gid: 'empire gid', |
|
|
|
|
|
|
|
empire: 'empire', |
|
|
|
|
|
|
|
empire_a: 'empire abbr' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const actual = geojsonify({}, input); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const expected = { |
|
|
|
|
|
|
|
type: 'FeatureCollection', |
|
|
|
|
|
|
|
features: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'Feature', |
|
|
|
|
|
|
|
geometry: { |
|
|
|
|
|
|
|
type: 'Point', |
|
|
|
|
|
|
|
coordinates: [ 21.212121, 12.121212 ] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
properties: { |
|
|
|
|
|
|
|
id: 'id 1', |
|
|
|
|
|
|
|
gid: 'source 1:layer 1:id 1', |
|
|
|
|
|
|
|
layer: 'layer 1', |
|
|
|
|
|
|
|
source: 'source 1', |
|
|
|
|
|
|
|
source_id: 'source_id 1', |
|
|
|
|
|
|
|
name: 'name 1', |
|
|
|
|
|
|
|
country_gid: 'country gid', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: 'Feature', |
|
|
|
|
|
|
|
geometry: { |
|
|
|
|
|
|
|
type: 'Point', |
|
|
|
|
|
|
|
coordinates: [ 31.313131, 13.131313 ] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
properties: { |
|
|
|
|
|
|
|
id: 'id 2', |
|
|
|
|
|
|
|
gid: 'source 2:layer 2:id 2', |
|
|
|
|
|
|
|
layer: 'layer 2', |
|
|
|
|
|
|
|
source: 'source 2', |
|
|
|
|
|
|
|
source_id: 'source_id 2', |
|
|
|
|
|
|
|
name: 'name 2', |
|
|
|
|
|
|
|
empire_gid: 'empire gid', |
|
|
|
|
|
|
|
empire: 'empire', |
|
|
|
|
|
|
|
empire_a: 'empire abbr' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
bbox: [21.212121, 12.121212, 31.313131, 13.131313] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.deepEquals(actual, expected); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
module.exports.all = (tape, common) => { |
|
|
|
module.exports.all = (tape, common) => { |
|
|
|