-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow QAPage to set URL for author (#1479)
- Loading branch information
Showing
6 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import QAPageJsonLd, { QAPageJsonLdProps } from '../qaPage'; | ||
|
||
describe('QAPage JSON-LD', () => { | ||
it('renders author with given URL', () => { | ||
const props: QAPageJsonLdProps = { | ||
mainEntity: { | ||
'@type': 'Question', | ||
name: 'nameString', | ||
text: 'textString', | ||
author: { | ||
name: 'johndoe', | ||
url: 'https://example.com/author/johndoe', | ||
}, | ||
}, | ||
scriptId: 'jsonld-qa-page', | ||
}; | ||
|
||
render(<QAPageJsonLd {...props} />); | ||
|
||
const script = screen.getByTestId('jsonld-qa-page'); | ||
|
||
const expected = { | ||
'@context': 'https://schema.org', | ||
'@type': 'QAPage', | ||
mainEntity: { | ||
'@type': 'Question', | ||
name: 'nameString', | ||
text: 'textString', | ||
author: { | ||
'@type': 'Person', | ||
name: 'johndoe', | ||
url: 'https://example.com/author/johndoe', | ||
}, | ||
}, | ||
}; | ||
|
||
expect(script.innerHTML).toEqual(JSON.stringify(expected)); | ||
}); | ||
|
||
it('renders author default JSON with name only', () => { | ||
const props: QAPageJsonLdProps = { | ||
mainEntity: { | ||
'@type': 'Question', | ||
name: 'nameString', | ||
text: 'textString', | ||
author: 'johndoe', | ||
}, | ||
scriptId: 'jsonld-qa-page', | ||
}; | ||
|
||
render(<QAPageJsonLd {...props} />); | ||
|
||
const script = screen.getByTestId('jsonld-qa-page'); | ||
|
||
const expected = { | ||
'@context': 'https://schema.org', | ||
'@type': 'QAPage', | ||
mainEntity: { | ||
'@type': 'Question', | ||
name: 'nameString', | ||
text: 'textString', | ||
author: { | ||
'@type': 'Person', | ||
name: 'johndoe', | ||
}, | ||
}, | ||
}; | ||
|
||
expect(script.innerHTML).toEqual(JSON.stringify(expected)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters