Skip to content

Commit

Permalink
Add test for 'auto' option
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Mar 11, 2020
1 parent 23732d0 commit 460eba5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions __tests__/parsing-and-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 460eba5

Please sign in to comment.