Skip to content

Commit

Permalink
feat: Merge pull request #81 from sweco-semhul/adding-address-unit
Browse files Browse the repository at this point in the history
Adding unit field to address in Document and tests for it
  • Loading branch information
orangejulius authored Nov 20, 2017
2 parents b42afd4 + bfaca06 commit 75cae37
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions test/document/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
4 changes: 3 additions & 1 deletion test/document/toESDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 75cae37

Please sign in to comment.