From deaea22c4df35fafc74cd7720b7e1e8ed518fea7 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 29 Sep 2016 09:16:25 +0200 Subject: [PATCH] more thorough js tests --- tests.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests.js b/tests.js index 97d7b12..3a7b879 100644 --- a/tests.js +++ b/tests.js @@ -37,23 +37,40 @@ if (credsWithDns.length) { */ var requiredFields = ['password', 'publicKey', 'contact']; +var recommendedFields = ['gpg']; var insufficientFields = Peers.filter(function (x, p) { var problem = false; + var comment = false; + + var path = '/' + p.join('/'); + + var requiredMsg = "[%s] => %s is missing the required field '%s'"; + var recommendedMsg = "[%s] => '%s' is missing the recommended field '%s'"; Object.keys(x).map(function (k) { var cred = x[k]; var fields = Object.keys(cred); - requiredFields.forEach(function (field) { - if (fields.indexOf(field) === -1) { - problem = true; - } + + recommendedFields.forEach(function (field) { + if (typeof(cred[field]) !== 'undefined') { return; } + console.log(recommendedMsg, path, k, field); + comment = true; + problem = true; }); + + requiredFields.forEach(function (field) { + if (typeof(cred[field]) !== 'undefined') { return; } + console.error(requiredMsg, path, k, field); + problem = true; + }) }); + + //if (comment || problem) { console.log(); } return problem; }); if (insufficientFields.length) { - console.log("The following peers did not have all the required fields"); - console.log(insufficientFields); + //console.log("The following peers did not have all the required fields"); + //console.log(insufficientFields); }