|
| 1 | +import { assertSchema } from '@cypress/schema-tools'; |
| 2 | +import schemas from '../schemas'; |
| 3 | + |
| 4 | +describe('WebPage JSON-LD', () => { |
| 5 | + it('matches schema', () => { |
| 6 | + cy.visit('http://localhost:3000/jsonld/webSite'); |
| 7 | + cy.get('head script[type="application/ld+json"]').then(tags => { |
| 8 | + const jsonLD = JSON.parse(tags[0].innerHTML); |
| 9 | + assertSchema(schemas)('WebSite', '1.0.0')(jsonLD); |
| 10 | + }); |
| 11 | + }); |
| 12 | + |
| 13 | + it('renders with all props', () => { |
| 14 | + cy.visit('http://localhost:3000/jsonld/webSite'); |
| 15 | + cy.get('head script[type="application/ld+json"]').then(tags => { |
| 16 | + const jsonLD = JSON.parse(tags[0].innerHTML); |
| 17 | + expect(jsonLD).to.deep.equal({ |
| 18 | + '@context': 'https://schema.org', |
| 19 | + '@type': 'WebSite', |
| 20 | + name: 'Example', |
| 21 | + alternateName: ['Example Org', 'Example Organization'], |
| 22 | + url: 'https://example.org', |
| 23 | + publisher: { |
| 24 | + '@id': 'https://example.org/#organization', |
| 25 | + }, |
| 26 | + }); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + it('renders without a publisher', () => { |
| 31 | + cy.visit('http://localhost:3000/jsonld/webSite/withoutPublisher'); |
| 32 | + cy.get('head script[type="application/ld+json"]').then(tags => { |
| 33 | + const jsonLD = JSON.parse(tags[0].innerHTML); |
| 34 | + expect(jsonLD).to.deep.equal({ |
| 35 | + '@context': 'https://schema.org', |
| 36 | + '@type': 'WebSite', |
| 37 | + name: 'Example', |
| 38 | + alternateName: ['Example Org', 'Example Organization'], |
| 39 | + url: 'https://example.org', |
| 40 | + }); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + it('renders with a single alternate name', () => { |
| 45 | + cy.visit('http://localhost:3000/jsonld/webSite/withSingleAlternateName'); |
| 46 | + cy.get('head script[type="application/ld+json"]').then(tags => { |
| 47 | + const jsonLD = JSON.parse(tags[0].innerHTML); |
| 48 | + expect(jsonLD).to.deep.equal({ |
| 49 | + '@context': 'https://schema.org', |
| 50 | + '@type': 'WebSite', |
| 51 | + name: 'Example', |
| 52 | + alternateName: 'Example Organization', |
| 53 | + url: 'https://example.org', |
| 54 | + }); |
| 55 | + }); |
| 56 | + }); |
| 57 | +}); |
0 commit comments