import React from "react"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx"
describe("Markdown component", function () {
describe("Swagger 2.0", function () {
it("allows elements with class, style and data-* attribs", function () {
const getConfigs = () => ({ useUnsafeMarkdown: true })
const str = `ONE`
const el = render()
expect(el.prop("outerHTML")).toEqual(`
`)
})
it("strips class, style and data-* attribs from elements", function () {
const getConfigs = () => ({ useUnsafeMarkdown: false })
const str = `ONE`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows td elements with colspan attrib", function () {
const str = ``
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows image elements", function () {
const str = `![Image alt text](http://image.source "Image title")`
const el = render()
expect(el.prop("outerHTML")).toEqual(`\n
`)
})
it("allows image elements with https scheme", function () {
const str = `![Image alt text](https://image.source "Image title")`
const el = render()
expect(el.prop("outerHTML")).toEqual(`\n
`)
})
it("allows image elements with data scheme", function () {
const str = ``
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows heading elements", function () {
const str = `
# h1
## h2
### h3
#### h4
##### h5
###### h6`
const el = render()
expect(el.prop("outerHTML")).toEqual(`h1
\nh2
\nh3
\nh4
\nh5
\nh6
\n`)
})
it("allows links", function () {
const str = `[Link](https://example.com/)`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
})
describe("OAS 3", function () {
it("allows elements with class, style and data-* attribs", function () {
const getConfigs = () => ({ useUnsafeMarkdown: true })
const str = `ONE`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("strips class, style and data-* attribs from elements", function () {
const getConfigs = () => ({ useUnsafeMarkdown: false })
const str = `ONE`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows image elements", function () {
const str = `![Image alt text](http://image.source "Image title")`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows image elements with https scheme", function () {
const str = `![Image alt text](https://image.source "Image title")`
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows image elements with data scheme", function () {
const str = ``
const el = render()
expect(el.prop("outerHTML")).toEqual(``)
})
it("allows heading elements", function () {
const str = `
# h1
## h2
### h3
#### h4
##### h5
###### h6`
const el = render()
expect(el.prop("outerHTML")).toEqual(`h1
\nh2
\nh3
\nh4
\nh5
\nh6
`)
})
})
})