Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unit field to address in Document and tests for it #81

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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