From 6cb5402fac542af348e8f8016eaccd381a3700b3 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Mon, 8 Jul 2019 14:40:59 +0200 Subject: [PATCH] fix: allow list of values for 'accessModeSufficient' Fixes #238 --- packages/ace-core/src/checker/checker-epub.js | 3 +++ tests/__tests__/epub-rules.test.js | 7 +++++++ tests/data/epubrules-metadata/EPUB/package.opf | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/ace-core/src/checker/checker-epub.js b/packages/ace-core/src/checker/checker-epub.js index e76ec873..f5399bf6 100644 --- a/packages/ace-core/src/checker/checker-epub.js +++ b/packages/ace-core/src/checker/checker-epub.js @@ -159,6 +159,9 @@ function checkMetadata(assertions, epub) { if (!Array.isArray(values)) { values = [values] } + // Parse list values + values = values.map(value => value.trim().replace(',', ' ').replace(/\s{2,}/g, ' ').split(' ')) + values = [].concat(...values); // Check metadata values are allowed // see https://www.w3.org/wiki/WebSchemas/Accessibility if (meta.allowedValues) { diff --git a/tests/__tests__/epub-rules.test.js b/tests/__tests__/epub-rules.test.js index ee85c098..b8ca185d 100644 --- a/tests/__tests__/epub-rules.test.js +++ b/tests/__tests__/epub-rules.test.js @@ -77,6 +77,13 @@ describe('accessibility metadata', () => { }), }), ])); + expect(assertions).not.toEqual(expect.arrayContaining([ + expect.objectContaining({ + 'earl:test': expect.objectContaining({ + 'dct:title': 'metadata-accessmodesufficient-invalid', + }), + }), + ])); }); test('`printPageNumbers` is declared as a feature but the Nav Doc has no page list', async () => { const report = await ace('../data/epubrules-metadata-printPageNumbers-nopagelist'); diff --git a/tests/data/epubrules-metadata/EPUB/package.opf b/tests/data/epubrules-metadata/EPUB/package.opf index 0e136fac..19f543a8 100644 --- a/tests/data/epubrules-metadata/EPUB/package.opf +++ b/tests/data/epubrules-metadata/EPUB/package.opf @@ -13,7 +13,7 @@ noMotionSimulationHazard text - textual + visual,textual