-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for license URL precedence in AdditionalInfo component
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,6 +267,39 @@ describe('HttpService', () => { | |
expect(title).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render additional information with SPDX license identifier', () => { | ||
const contact = { | ||
name: 'Developer', | ||
email: '[email protected]', | ||
url: 'https://stoplight.io/contact-us/', | ||
}; | ||
|
||
const license = { | ||
name: 'MIT License', | ||
identifier: 'MIT', | ||
}; | ||
|
||
render( | ||
<AdditionalInfo id="a" contact={contact} license={license} termsOfService="https://stoplight.io/terms/" />, | ||
); | ||
|
||
const licenseLink = screen.getByText('MIT License'); | ||
expect(licenseLink).toHaveAttribute('href', 'https://spdx.org/licenses/MIT.html'); | ||
}); | ||
|
||
it('should prefer license URL over SPDX identifier if both are provided', () => { | ||
const license = { | ||
name: 'MIT License', | ||
url: 'https://opensource.org/licenses/MIT', | ||
identifier: 'MIT', | ||
}; | ||
|
||
render(<AdditionalInfo id="a" license={license} />); | ||
|
||
const licenseLink = screen.getByText('MIT License'); | ||
expect(licenseLink).toHaveAttribute('href', 'https://opensource.org/licenses/MIT'); | ||
}); | ||
|
||
it('should not render if contact, license, and terms of service do not exist', () => { | ||
render(<AdditionalInfo id="a" />); | ||
|
||
|