Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/core/components/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class License extends React.Component {
let { license, getComponent, selectedServer, url: specUrl } = this.props

const Link = getComponent("Link")
let name = license.get("name") || "License"
let name = license.get("name") || "License"
let url = buildUrl(license.get("url"), specUrl, {selectedServer})

return (
Expand Down Expand Up @@ -113,7 +113,12 @@ export default class Info extends React.Component {
let version = info.get("version")
let description = info.get("description")
let title = info.get("title")
let termsOfServiceUrl = buildUrl(info.get("termsOfService"), specUrl, {selectedServer})
let termsOfServiceUrl
try {
termsOfServiceUrl = buildUrl(info.get("termsOfService"), specUrl, {selectedServer})
} catch (error) {
termsOfServiceUrl = info.get("termsOfService")
}
let contact = info.get("contact")
let license = info.get("license")
let rawExternalDocsUrl = externalDocs && externalDocs.get("url")
Expand Down
33 changes: 33 additions & 0 deletions test/unit/components/info-wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("<InfoContainer/>", function () {
basePath () {},
host () {},
externalDocs () {},
termsOfService () {},
},
oas3Selectors: {
selectedServer () {},
Expand All @@ -37,6 +38,38 @@ describe("<InfoContainer/>", function () {
expect(renderedInfo.length).toEqual(1)
})

it("renders Info inside InfoContainer with inline termsOfService", function () {

// Given
let props = {...mockedProps}
props.specSelectors = {...mockedProps.specSelectors}
props.specSelectors.info = function () {return fromJS(["info1"])}
props.specSelectors.info.termsOfService = "foo bar baz"

// When
let wrapper = mount(<InfoContainer {...props}/>)

// Then
const renderedInfo = wrapper.find("span.mocked-info")
expect(renderedInfo.length).toEqual(1)
})

it("renders Info inside InfoContainer with termsOfService URL", function () {

// Given
let props = {...mockedProps}
props.specSelectors = {...mockedProps.specSelectors}
props.specSelectors.info = function () {return fromJS(["info1"])}
props.specSelectors.info.termsOfService = "https://foo.bar/baz"

// When
let wrapper = mount(<InfoContainer {...props}/>)

// Then
const renderedInfo = wrapper.find("span.mocked-info")
expect(renderedInfo.length).toEqual(1)
})

it("does not render Info inside InfoContainer if no info is provided", function () {

// Given
Expand Down