Some checks failed
Node.js CI / build (push) Failing after 2s
Node.js CI / e2e-tests (+(a11y|security|bugs)/**/*cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/!(o|d|m)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/+(o|d)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/m*.cy.js) (push) Failing after 2s
CodeQL / Analyze (javascript) (push) Failing after 2m49s
Security scan for docker image / build (push) Failing after 54s
30 lines
922 B
JavaScript
Executable File
30 lines
922 B
JavaScript
Executable File
import React from "react"
|
|
import { mount } from "enzyme"
|
|
import OnlineValidatorBadge from "core/components/online-validator-badge"
|
|
|
|
describe("<OnlineValidatorBadge/> Anchor Target Safety", function () {
|
|
it("should render a validator link with safe `rel` attributes", function () {
|
|
// When
|
|
const props = {
|
|
getConfigs: () => ({}),
|
|
getComponent: () => null,
|
|
specSelectors: {
|
|
url: () => "https://smartbear.com/swagger.json"
|
|
}
|
|
}
|
|
const wrapper = mount(
|
|
<OnlineValidatorBadge {...props} />
|
|
)
|
|
|
|
const anchor = wrapper.find("a")
|
|
|
|
// Then
|
|
expect(anchor.props().href).toEqual(
|
|
"https://validator.swagger.io/validator/debug?url=https%3A%2F%2Fsmartbear.com%2Fswagger.json"
|
|
)
|
|
expect(anchor.props().target).toEqual("_blank")
|
|
expect(anchor.props().rel || "").toContain("noopener")
|
|
expect(anchor.props().rel || "").toContain("noreferrer")
|
|
})
|
|
})
|