|
|
@ -519,6 +519,164 @@ module.exports.tests.success = (test, common) => { |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('only results matching explicit layers should be returned', (t) => { |
|
|
|
|
|
|
|
let placeholderService_was_called = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const placeholder_response = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 1, |
|
|
|
|
|
|
|
name: 'name 1', |
|
|
|
|
|
|
|
placetype: 'neighbourhood', |
|
|
|
|
|
|
|
lineage: [ {} ], |
|
|
|
|
|
|
|
geom: { |
|
|
|
|
|
|
|
area: 1, |
|
|
|
|
|
|
|
lat: 14.141414, |
|
|
|
|
|
|
|
lon: 41.414141 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 2, |
|
|
|
|
|
|
|
name: 'name 2', |
|
|
|
|
|
|
|
placetype: 'borough', |
|
|
|
|
|
|
|
lineage: [ {} ], |
|
|
|
|
|
|
|
geom: { |
|
|
|
|
|
|
|
area: 2, |
|
|
|
|
|
|
|
lat: 15.151515, |
|
|
|
|
|
|
|
lon: 51.515151 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 3, |
|
|
|
|
|
|
|
name: 'name 3', |
|
|
|
|
|
|
|
placetype: 'locality', |
|
|
|
|
|
|
|
lineage: [ {} ], |
|
|
|
|
|
|
|
geom: { |
|
|
|
|
|
|
|
area: 3, |
|
|
|
|
|
|
|
lat: 16.161616, |
|
|
|
|
|
|
|
lon: 61.616161 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 4, |
|
|
|
|
|
|
|
name: 'name 4', |
|
|
|
|
|
|
|
placetype: 'localadmin', |
|
|
|
|
|
|
|
lineage: [ {} ], |
|
|
|
|
|
|
|
geom: { |
|
|
|
|
|
|
|
area: 4, |
|
|
|
|
|
|
|
lat: 17.171717, |
|
|
|
|
|
|
|
lon: 71.717171 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 5, |
|
|
|
|
|
|
|
name: 'name 5', |
|
|
|
|
|
|
|
placetype: 'county', |
|
|
|
|
|
|
|
lineage: [ {} ], |
|
|
|
|
|
|
|
geom: { |
|
|
|
|
|
|
|
area: 5, |
|
|
|
|
|
|
|
lat: 18.181818, |
|
|
|
|
|
|
|
lon: 81.818181 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const placeholderService = (req, callback) => { |
|
|
|
|
|
|
|
t.deepEqual(req, { |
|
|
|
|
|
|
|
param1: 'param1 value', |
|
|
|
|
|
|
|
clean: { |
|
|
|
|
|
|
|
layers: ['neighbourhood', 'locality', 'county'] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
placeholderService_was_called = true; |
|
|
|
|
|
|
|
callback(null, placeholder_response); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const should_execute = (req, res) => { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const controller = placeholder(placeholderService, should_execute); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const req = { |
|
|
|
|
|
|
|
param1: 'param1 value', |
|
|
|
|
|
|
|
clean: { |
|
|
|
|
|
|
|
layers: [ |
|
|
|
|
|
|
|
'neighbourhood', |
|
|
|
|
|
|
|
'locality', |
|
|
|
|
|
|
|
'county' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const res = { }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const expected_res = { |
|
|
|
|
|
|
|
meta: {}, |
|
|
|
|
|
|
|
data: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_id: '1', |
|
|
|
|
|
|
|
_type: 'neighbourhood', |
|
|
|
|
|
|
|
layer: 'neighbourhood', |
|
|
|
|
|
|
|
source: 'whosonfirst', |
|
|
|
|
|
|
|
source_id: '1', |
|
|
|
|
|
|
|
center_point: { |
|
|
|
|
|
|
|
lat: 14.141414, |
|
|
|
|
|
|
|
lon: 41.414141 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
name: { |
|
|
|
|
|
|
|
'default': 'name 1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
phrase: { |
|
|
|
|
|
|
|
'default': 'name 1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
parent: { } |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_id: '3', |
|
|
|
|
|
|
|
_type: 'locality', |
|
|
|
|
|
|
|
layer: 'locality', |
|
|
|
|
|
|
|
source: 'whosonfirst', |
|
|
|
|
|
|
|
source_id: '3', |
|
|
|
|
|
|
|
center_point: { |
|
|
|
|
|
|
|
lat: 16.161616, |
|
|
|
|
|
|
|
lon: 61.616161 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
name: { |
|
|
|
|
|
|
|
'default': 'name 3' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
phrase: { |
|
|
|
|
|
|
|
'default': 'name 3' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
parent: { } |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_id: '5', |
|
|
|
|
|
|
|
_type: 'county', |
|
|
|
|
|
|
|
layer: 'county', |
|
|
|
|
|
|
|
source: 'whosonfirst', |
|
|
|
|
|
|
|
source_id: '5', |
|
|
|
|
|
|
|
center_point: { |
|
|
|
|
|
|
|
lat: 18.181818, |
|
|
|
|
|
|
|
lon: 81.818181 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
name: { |
|
|
|
|
|
|
|
'default': 'name 5' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
phrase: { |
|
|
|
|
|
|
|
'default': 'name 5' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
parent: { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller(req, res, () => { |
|
|
|
|
|
|
|
t.ok(placeholderService_was_called); |
|
|
|
|
|
|
|
t.deepEquals(res, expected_res); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.error_conditions = (test, common) => { |
|
|
|
module.exports.tests.error_conditions = (test, common) => { |
|
|
|