From 09522aa2b0e95493d9623a2095e5c56714922c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Mon, 16 Dec 2019 10:51:20 +0100 Subject: [PATCH] Emit null instead of empty object for `validateAshHooks` This was left to minimize report.json changes in earlier refactoring. Fixing it now should only affect the report.json structure but not report.html. --- lib/validator.js | 7 ++----- test/validator.js | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/validator.js b/lib/validator.js index 77ba6fcf..363ab010 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -186,16 +186,13 @@ const ashnazgHookUrls = [ ]; function validateAshHooks(hooks) { - // Note: unlike `reportError` used above, here empty object literals are - // pushed instead of nulls. This is simply to match the original structure - // of report.json. TODO: change this to null, or add error details. const errors = []; const ashHooks = hooks.filter(h => ashnazgHookUrls.includes(h.config.url) && h.config.contentType === "json" && h.config.insecureSsl === "0" && h.config.secret !== ""); if (ashHooks.length === 0) { - errors.push(['missingashnazghook', {}]); + errors.push(['missingashnazghook', null]); } if (ashHooks.length > 1) { - errors.push(['duplicateashnazghooks', {}]); + errors.push(['duplicateashnazghooks', null]); } return errors; } diff --git a/test/validator.js b/test/validator.js index d30460d0..fe546bce 100644 --- a/test/validator.js +++ b/test/validator.js @@ -411,7 +411,7 @@ describe('validateAshHooks', () => { it('no hooks', () => { const hooks = []; const errors = validateAshHooks(hooks); - assert.deepStrictEqual(errors, [['missingashnazghook', {}]]); + assert.deepStrictEqual(errors, [['missingashnazghook', null]]); }); it('one hook', () => { @@ -444,6 +444,6 @@ describe('validateAshHooks', () => { } }]; const errors = validateAshHooks(hooks); - assert.deepStrictEqual(errors, [['duplicateashnazghooks', {}]]); + assert.deepStrictEqual(errors, [['duplicateashnazghooks', null]]); }); });