From 0f6059c05a8a443376c8a39bca030e289733f304 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Thu, 3 Mar 2016 10:04:28 -0500 Subject: [PATCH] Refactored to use a function for looking up value for a label The reason for this switch is that special case logic is needed to determine the US state name to display. All other fields can be looked up by name. The burden of fallback functionality is now in `helper/labelSchema` so the burden of unit testing is now in `test/unit/helper/labelSchema.js` --- helper/labelGenerator.js | 17 +- helper/labelSchema.js | 65 ++- test/unit/helper/labelGenerator_USA.js | 13 +- test/unit/helper/labelSchema.js | 661 +++++++++++++++++++++++-- 4 files changed, 695 insertions(+), 61 deletions(-) diff --git a/helper/labelGenerator.js b/helper/labelGenerator.js index 31a04414..e772ceb9 100644 --- a/helper/labelGenerator.js +++ b/helper/labelGenerator.js @@ -1,6 +1,5 @@ var _ = require('lodash'), - check = require('check-types'), schemas = require('./labelSchema'); module.exports = function( record ){ @@ -8,19 +7,11 @@ module.exports = function( record ){ var labelParts = getInitialLabel(record); - var buildOutput = function(parts, schemaArr, record) { - for (var i=0; i