From 460eba5d74ba54271d97d57927ad0e7c491f8615 Mon Sep 17 00:00:00 2001 From: Iain Collins Date: Wed, 11 Mar 2020 09:36:46 +0000 Subject: [PATCH] Add test for 'auto' option --- __tests__/parsing-and-options.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/__tests__/parsing-and-options.js b/__tests__/parsing-and-options.js index 42b5fdb..58aae6e 100644 --- a/__tests__/parsing-and-options.js +++ b/__tests__/parsing-and-options.js @@ -70,6 +70,31 @@ describe('Parsing and options', () => { } }) + test(`should not automatically run tests for structured data found when the 'auto' option is set to 'false'`, async () => { + const options = { + tests: [ + { test: 'ReportageNewsArticle', expect: true }, + { test: 'ReportageNewsArticle[*]."@type"', expect: 'ReportageNewsArticle' }, + { test: 'ReportageNewsArticle[*]."@context"', expect: 'http://schema.org' }, + { test: 'ReportageNewsArticle[*].url', expect: 'http://example.com/path-to-article', type: 'any' }, + { test: 'ReportageNewsArticle[*].headline', expect: 'Example Headline in JSON-LD', type: 'jsonld' }, + { test: 'Article[*].headline', expect: 'Example Headline in Microdata', type: 'microdata' }, + { test: 'NewsArticle[*].headline', expect: 'Example Headline in RDFa', type: 'rdfa' }, + { test: '"twitter:card"', expect: 'summary_large_image', type: 'metatag' } + ], + auto: false + } + try { + const result = await structuredDataTestUrl("https://example.com", options) + expect(result.passed.length).toEqual(8) + expect(result.failed.length).toEqual(0) + } catch (e) { + console.error("Failing tests:", e.failed) + throw e + } + }) + + test('should run all tests passed as options and for any schemas found and any presets specified', async () => { const options = { tests: [