From bfaca06cb0ab64e2f92801be1765550f42e7e714 Mon Sep 17 00:00:00 2001 From: sweco-semhul Date: Thu, 19 Oct 2017 11:32:54 +0200 Subject: [PATCH] Adding unit to address in Document and tests for it --- Document.js | 2 +- test/document/address.js | 2 ++ test/document/toESDocument.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Document.js b/Document.js index 763f7d4..6594d71 100644 --- a/Document.js +++ b/Document.js @@ -4,7 +4,7 @@ var validate = require('./util/valid'); var transform = require('./util/transform'); var _ = require('lodash'); -const addressFields = ['name', 'number', 'street', 'zip']; +const addressFields = ['name', 'number', 'unit', 'street', 'zip']; const parentFields = [ 'continent', diff --git a/test/document/address.js b/test/document/address.js index 9c5528b..68f8ed1 100644 --- a/test/document/address.js +++ b/test/document/address.js @@ -27,11 +27,13 @@ module.exports.tests.setAddress = function(test) { t.throws( doc.setAddress.bind(doc, 'foo', 1), null, 'invalid property' ); t.throws( doc.setAddress.bind(doc, '4', 2), null, 'invalid property' ); t.throws( doc.setAddress.bind(doc, 'zip', 2), null, 'invalid property' ); + t.throws( doc.setAddress.bind(doc, 'unit', 2), null, 'invalid property' ); t.throws( doc.setAddress.bind(doc, 'street', true), null, 'invalid property' ); t.throws( doc.setAddress.bind(doc, 'street', null), null, 'invalid property' ); t.throws( doc.setAddress.bind(doc, 'street', '\n'), null, 'invalid property' ); t.equal(doc.address_parts.street, undefined, 'property unchanged'); t.doesNotThrow( doc.setAddress.bind(doc, 'zip', 'foo'), null, 'invalid property' ); + t.doesNotThrow( doc.setAddress.bind(doc, 'unit', 'foo'), null, 'invalid property' ); t.doesNotThrow( doc.setAddress.bind(doc, 'street', '1'), null, 'invalid property' ); t.end(); }); diff --git a/test/document/toESDocument.js b/test/document/toESDocument.js index ce36609..4922afc 100644 --- a/test/document/toESDocument.js +++ b/test/document/toESDocument.js @@ -25,6 +25,7 @@ module.exports.tests.toESDocument = function(test) { doc.setAddress('number', 'address number'); doc.setAddress('street', 'address street'); doc.setAddress('zip', 'address zip'); + doc.setAddress('unit', 'address unit'); doc.setBoundingBox({ upperLeft: { lat: 13.131313, @@ -59,7 +60,8 @@ module.exports.tests.toESDocument = function(test) { name: 'address name', number: 'address number', street: 'address street', - zip: 'address zip' + zip: 'address zip', + unit: 'address unit' }, source: 'mysource', source_id: 'myid',