Skip to content

Commit

Permalink
added test for country iso3 lookup/set
Browse files Browse the repository at this point in the history
  • Loading branch information
trescube committed Jul 8, 2017
1 parent b01c372 commit 8702c79
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/peliasDocGeneratorsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,49 @@ tape('create', function(test) {

});

test.test('country with abbreviation known as iso3 should use iso3 as abbreviation', function(t) {
var wofRecords = {
1: {
id: 1,
name: 'record name',
abbreviation: 'FR',
lat: 12.121212,
lon: 21.212121,
place_type: 'country'
}
};

// extract all the values from wofRecords to an array since that's how test_stream works
// sure, this could be done with map, but this is clearer
var input = [
wofRecords['1']
];

var expected = [
new Document( 'whosonfirst', 'country', '1')
.setName('default', 'record name')
.setCentroid({ lat: 12.121212, lon: 21.212121 })
.addParent( 'country', 'record name', '1', 'FRA')
];

var hierarchies_finder = function() {
return [
[
wofRecords['1']
]
];
};

var docGenerator = peliasDocGenerators.create(hierarchies_finder);

test_stream(input, docGenerator, function(err, actual) {
t.deepEqual(actual, expected, 'should have returned true');
});

t.end();

});

test.test('wofRecord with bounding_box should have bounding box in Document', function(t) {
var wofRecords = {
1: {
Expand Down

0 comments on commit 8702c79

Please sign in to comment.