forked from pelias/schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbounding_box.js
53 lines (43 loc) · 1.4 KB
/
bounding_box.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// validate bounding box behaves as expected
const Suite = require('../test/elastictest/Suite');
const config = require('pelias-config').generate();
module.exports.tests = {};
module.exports.tests.index_and_retrieve = function(test, common){
test( 'index and retrieve', function(t){
var suite = new Suite( common.clientOpts, common.create );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up
// index a document with a bbox
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
id: '1',
body: {
bounding_box: '{"min_lat":-47.75,"max_lat":-33.9,"min_lon":163.82,"max_lon":179.42}'
}
}, done);
});
// retrieve document by id
suite.assert( function( done ) {
suite.client.get(
{
index: suite.props.index,
id: '1'
},
function (err, res) {
t.equal(err, undefined);
t.deepEqual(res._source.bounding_box, '{"min_lat":-47.75,"max_lat":-33.9,"min_lon":163.82,"max_lon":179.42}');
done();
}
);
});
suite.run( t.end );
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('bounding box: ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};