Skip to content

Commit

Permalink
Add unit tests for license URL precedence in AdditionalInfo component
Browse files Browse the repository at this point in the history
  • Loading branch information
elmiomar committed Oct 15, 2024
1 parent a1e3b01 commit a2398e5
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" />);

Expand Down

0 comments on commit a2398e5

Please sign in to comment.