From 9e20be3397fde456ae770cc7d4dfe95cfc2eff3f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 3 Jan 2024 20:32:23 -0400 Subject: validators: validateArrayItems: nest in a cause layer --- test/unit/data/things/validators.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'test/unit') diff --git a/test/unit/data/things/validators.js b/test/unit/data/things/validators.js index 27d5f4f1..178f8657 100644 --- a/test/unit/data/things/validators.js +++ b/test/unit/data/things/validators.js @@ -115,7 +115,7 @@ test(t, 'isObject', t => { }); test(t, 'validateArrayItems', t => { - t.plan(6); + t.plan(9); t.ok(validateArrayItems(isNumber)([3, 4, 5])); t.ok(validateArrayItems(validateArrayItems(isNumber))([[3, 4], [4, 5], [6, 7]])); @@ -130,7 +130,10 @@ test(t, 'validateArrayItems', t => { t.not(caughtError, null); t.ok(caughtError instanceof AggregateError); t.equal(caughtError.errors.length, 1); - t.ok(caughtError.errors[0] instanceof TypeError); + t.ok(caughtError.errors[0] instanceof Error); + t.equal(caughtError.errors[0][Symbol.for('hsmusic.annotateError.indexInSourceArray')], 2); + t.not(caughtError.errors[0].cause, null); + t.ok(caughtError.errors[0].cause instanceof TypeError); }); // Wiki data @@ -267,7 +270,7 @@ test(t, 'validateReferenceList', t => { const track = validateReferenceList('track'); const artist = validateReferenceList('artist'); - t.plan(9); + t.plan(11); t.ok(track(['track:fallen-down', 'Once Upon a Time'])); t.ok(artist(['artist:toby-fox', 'Mark Hadley'])); @@ -284,8 +287,10 @@ test(t, 'validateReferenceList', t => { t.not(caughtError, null); t.ok(caughtError instanceof AggregateError); t.equal(caughtError.errors.length, 2); - t.ok(caughtError.errors[0] instanceof TypeError); - t.ok(caughtError.errors[1] instanceof TypeError); + t.ok(caughtError.errors[0] instanceof Error); + t.ok(caughtError.errors[0].cause instanceof TypeError); + t.ok(caughtError.errors[1] instanceof Error); + t.ok(caughtError.errors[0].cause instanceof TypeError); }); test(t, 'anyOf', t => { -- cgit 1.3.0-6-gf8a5