poly-js-utils
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "poly-js-utils", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Common client-side tools used in HSS Sites themes and locators.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -97,2 +97,23 @@ var viewHelpers = require('../src/view-helpers'); | ||
}); | ||
it("should be able to take a list of fields, if we want some different ones", function() { | ||
var alternativeAddress = { | ||
planet: "Earth", | ||
country: "USA", | ||
state: "WA", | ||
city: "Seattle", | ||
zipCode: 98109, | ||
foo: "bar" | ||
}; | ||
var fields = ["city", "state", "zipCode", "country", "planet"]; | ||
var expected = "Seattle, WA 98109 USA Earth"; | ||
expect(viewHelpers.printAddress(alternativeAddress, fields)).toBe(expected); | ||
}); | ||
it("should ignore non-existent fields specified as arguments", function() { | ||
var fields = ["city", "state", "zipCode", "country", "planet"]; | ||
var expected = "Seattle, WA USA"; | ||
expect(viewHelpers.printAddress(address, fields)).toBe(expected); | ||
}); | ||
}); | ||
@@ -99,0 +120,0 @@ |
@@ -101,5 +101,5 @@ /****************************/ | ||
/* Combine address elements into single string. */ | ||
var printAddress = function(address) { | ||
var printAddress = function(address, fields) { | ||
address.city = address.city && address.city + ","; | ||
var fields = ["street", "suite", "city", "state", "country", "zip_code"]; | ||
var fields = fields || ["street", "suite", "city", "state", "country", "zip_code"]; | ||
var fullAddress = _.chain(fields) | ||
@@ -106,0 +106,0 @@ .map(_.propertyOf(address)) |
89000
1914