From 5f445ade2bd15c77ee9d62b4075ad11a3d8b3bbc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 3 Feb 2023 13:12:12 +0200 Subject: [PATCH] feature: validate: add support of any symbol before ":" --- packages/supertape/lib/validator.js | 2 +- packages/supertape/lib/validator.spec.js | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/supertape/lib/validator.js b/packages/supertape/lib/validator.js index effd978..df05961 100644 --- a/packages/supertape/lib/validator.js +++ b/packages/supertape/lib/validator.js @@ -8,7 +8,7 @@ const getMessage = ({message, at, validations}) => [message, at, validations]; const getMessagesList = (tests) => tests.map(getMessage); const compareMessage = (a) => ([b]) => a === b; -const SCOPE_DEFINED = /^[@\w-/\d\s]+:.*/; +const SCOPE_DEFINED = /^.*[\w-/\d\s]+:.*/; const processedList = new Set(); const validations = { diff --git a/packages/supertape/lib/validator.spec.js b/packages/supertape/lib/validator.spec.js index a75f003..ae6b6d2 100644 --- a/packages/supertape/lib/validator.spec.js +++ b/packages/supertape/lib/validator.spec.js @@ -110,6 +110,33 @@ test('supertape: validator: checkScopes: @', (t) => { t.end(); }); +test('supertape: validator: checkScopes: +', (t) => { + const { + createValidator, + setValidations, + } = reRequire('./validator'); + const current = { + message: '+hello: world', + at: 'at', + }; + + const tests = [current]; + + setValidations({ + checkScopes: true, + }); + + const validate = createValidator({ + tests, + }); + + const result = validate('+hello: world'); + const expected = []; + + t.deepEqual(result, expected); + t.end(); +}); + test('supertape: validator: checkAssertionsCount', (t) => { const { createValidator,